diff --git a/client/components/App.vue b/client/components/App.vue
index 12f35ecb..bc1642c3 100644
--- a/client/components/App.vue
+++ b/client/components/App.vue
@@ -2,7 +2,7 @@
-
+
diff --git a/client/js/router.js b/client/js/router.js
index 3a1d16b2..f0a0eca6 100644
--- a/client/js/router.js
+++ b/client/js/router.js
@@ -24,6 +24,38 @@ const router = new VueRouter({
windowName: "SignIn",
},
},
+ ],
+});
+
+router.afterEach((to) => {
+ if (!router.app.initialized) {
+ return;
+ }
+
+ router.app.closeSidebarIfNeeded();
+
+ if (!to.meta.isChat) {
+ // Navigating out of a chat window
+ store.commit("activeWindow", to.meta.windowName);
+
+ if (store.state.activeChannel && store.state.activeChannel.channel) {
+ router.app.switchOutOfChannel(store.state.activeChannel.channel);
+ }
+
+ store.commit("activeChannel", null);
+ }
+});
+
+function initialize() {
+ router.addRoutes([
+ {
+ path: "/sign-in",
+ component: SignIn,
+ meta: {
+ isChat: false,
+ windowName: "SignIn",
+ },
+ },
{
path: "/connect",
component: Connect,
@@ -72,26 +104,10 @@ const router = new VueRouter({
windowName: "RoutedChat",
},
},
- ],
-});
+ ]);
+}
-router.afterEach((to) => {
- if (!router.app.initialized) {
- return;
- }
-
- router.app.closeSidebarIfNeeded();
-
- if (!to.meta.isChat) {
- // Navigating out of a chat window
- store.commit("activeWindow", to.meta.windowName);
-
- if (store.state.activeChannel && store.state.activeChannel.channel) {
- router.app.switchOutOfChannel(store.state.activeChannel.channel);
- }
-
- store.commit("activeChannel", null);
- }
-});
-
-export default router;
+module.exports = {
+ initialize,
+ router,
+};
diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js
index 232c6365..f126de3f 100644
--- a/client/js/socket-events/init.js
+++ b/client/js/socket-events/init.js
@@ -8,6 +8,7 @@ const sidebar = $("#sidebar");
const storage = require("../localStorage");
const constants = require("../constants");
const {vueApp, initChannel} = require("../vue");
+const router = require("../router");
const store = require("../store").default;
socket.on("init", function(data) {
@@ -22,6 +23,7 @@ socket.on("init", function(data) {
store.commit("currentUserVisibleError", null);
if (!vueApp.initialized) {
+ router.initialize();
vueApp.onSocketInit();
if (data.token) {
diff --git a/client/js/vue.js b/client/js/vue.js
index 65e55190..0c11edd8 100644
--- a/client/js/vue.js
+++ b/client/js/vue.js
@@ -9,7 +9,7 @@ const localetime = require("./libs/handlebars/localetime");
const friendlysize = require("./libs/handlebars/friendlysize");
const colorClass = require("./libs/handlebars/colorClass");
const storage = require("./localStorage");
-const router = require("./router").default;
+const {router} = require("./router");
const constants = require("./constants");
Vue.filter("localetime", localetime);