diff --git a/client/js/socket-events/configuration.js b/client/js/socket-events/configuration.js index 44bdf521..f619f30b 100644 --- a/client/js/socket-events/configuration.js +++ b/client/js/socket-events/configuration.js @@ -3,7 +3,6 @@ import socket from "../socket"; import upload from "../upload"; import store from "../store"; -import {initialize as routerInitialize} from "../router"; socket.once("configuration", function(data) { store.commit("serverConfiguration", data); @@ -17,8 +16,6 @@ socket.once("configuration", function(data) { upload.initialize(); } - routerInitialize(); - // If localStorage contains a theme that does not exist on this server, switch // back to its default theme. const currentTheme = data.themes.find((t) => t.name === store.state.settings.theme); diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js index 2638867b..4174af2c 100644 --- a/client/js/socket-events/init.js +++ b/client/js/socket-events/init.js @@ -2,7 +2,7 @@ import socket from "../socket"; import storage from "../localStorage"; -import {router, switchToChannel, navigate} from "../router"; +import {router, switchToChannel, navigate, initialize as routerInitialize} from "../router"; import store from "../store"; import parseIrcUri from "../helpers/parseIrcUri"; @@ -16,6 +16,10 @@ socket.on("init", function(data) { } if (!store.state.appLoaded) { + // Routes are initialized after networks data is merged + // so the route guard for channels works correctly on page load + routerInitialize(); + store.commit("appLoaded"); if (window.g_TheLoungeRemoveLoading) { diff --git a/client/js/webpush.js b/client/js/webpush.js index f499eb47..4161dfeb 100644 --- a/client/js/webpush.js +++ b/client/js/webpush.js @@ -9,11 +9,12 @@ export default {togglePushSubscription}; if ("serviceWorker" in navigator) { navigator.serviceWorker.addEventListener("message", (event) => { if (event.data && event.data.type === "open") { - const id = event.data.channel.substr(5); // remove "chan-" prefix + const id = parseInt(event.data.channel.substr(5), 10); // remove "chan-" prefix + const channelTarget = store.getters.findChannel(id); if (channelTarget) { - switchToChannel(channelTarget); + switchToChannel(channelTarget.channel); } } });