Merge pull request #3663 from thelounge/xpaw/cyclical-dep
Remove cyclical dependency in router<->webpush
This commit is contained in:
commit
00cdb6e808
@ -142,4 +142,18 @@ function switchToChannel(channel) {
|
|||||||
return navigate("RoutedChat", {id: channel.id});
|
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};
|
export {initialize, router, navigate, switchToChannel};
|
||||||
|
@ -2,24 +2,9 @@
|
|||||||
|
|
||||||
import socket from "./socket";
|
import socket from "./socket";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
import {switchToChannel} from "./router";
|
|
||||||
|
|
||||||
export default {togglePushSubscription};
|
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) {
|
socket.once("push:issubscribed", function(hasSubscriptionOnServer) {
|
||||||
if (!isAllowedServiceWorkersHost()) {
|
if (!isAllowedServiceWorkersHost()) {
|
||||||
store.commit("pushNotificationState", "nohttps");
|
store.commit("pushNotificationState", "nohttps");
|
||||||
|
Loading…
Reference in New Issue
Block a user