mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +00:00
Remove cyclical dependency in router<->webpush
This commit is contained in:
parent
7b507e5248
commit
5fe0710724
2 changed files with 14 additions and 15 deletions
|
@ -142,4 +142,18 @@ function switchToChannel(channel) {
|
|||
return navigate("RoutedChat", {id: channel.id});
|
||||
}
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
||||
if (event.data && event.data.type === "open") {
|
||||
const id = parseInt(event.data.channel.substr(5), 10); // remove "chan-" prefix
|
||||
|
||||
const channelTarget = store.getters.findChannel(id);
|
||||
|
||||
if (channelTarget) {
|
||||
switchToChannel(channelTarget.channel);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export {initialize, router, navigate, switchToChannel};
|
||||
|
|
|
@ -2,24 +2,9 @@
|
|||
|
||||
import socket from "./socket";
|
||||
import store from "./store";
|
||||
import {switchToChannel} from "./router";
|
||||
|
||||
export default {togglePushSubscription};
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
||||
if (event.data && event.data.type === "open") {
|
||||
const id = parseInt(event.data.channel.substr(5), 10); // remove "chan-" prefix
|
||||
|
||||
const channelTarget = store.getters.findChannel(id);
|
||||
|
||||
if (channelTarget) {
|
||||
switchToChannel(channelTarget.channel);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
socket.once("push:issubscribed", function(hasSubscriptionOnServer) {
|
||||
if (!isAllowedServiceWorkersHost()) {
|
||||
store.commit("pushNotificationState", "nohttps");
|
||||
|
|
Loading…
Reference in a new issue