Fix opening channel when clicking a push notification

This commit is contained in:
Pavel Djundik 2019-11-25 21:51:04 +02:00
parent c2ed3fae56
commit a3be259567
3 changed files with 8 additions and 6 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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);
}
}
});