mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-07 08:46:41 +02:00
Address service-worker/notifications
This commit is contained in:
parent
b08120307d
commit
a37958f6a9
|
@ -23,7 +23,7 @@ export function generateChannelContextMenu($root, channel, network) {
|
|||
label: channel.name,
|
||||
type: "item",
|
||||
class: typeMap[channel.type],
|
||||
link: `/chan-${channel.id}`,
|
||||
link: `/${network.host}/${channel.name}`,
|
||||
},
|
||||
{
|
||||
type: "divider",
|
||||
|
|
|
@ -133,11 +133,14 @@ function notifyMessage(targetId, channel, activeChannel, msg) {
|
|||
const timestamp = Date.parse(msg.time);
|
||||
|
||||
try {
|
||||
const channelTarget = store.getters.findChannel(targetId);
|
||||
|
||||
if (store.state.hasServiceWorker) {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.active.postMessage({
|
||||
type: "notification",
|
||||
chanId: targetId,
|
||||
channelName: channelTarget.name,
|
||||
networkHost: channelTarget.network.host,
|
||||
timestamp: timestamp,
|
||||
title: title,
|
||||
body: body,
|
||||
|
@ -155,8 +158,6 @@ function notifyMessage(targetId, channel, activeChannel, msg) {
|
|||
this.close();
|
||||
window.focus();
|
||||
|
||||
const channelTarget = store.getters.findChannel(targetId);
|
||||
|
||||
if (channelTarget) {
|
||||
switchToChannel(channelTarget.network, channelTarget.channel);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ function showNotification(event, payload) {
|
|||
event.waitUntil(
|
||||
self.registration
|
||||
.getNotifications({
|
||||
tag: `chan-${payload.chanId}`,
|
||||
tag: `${payload.networkHost}/${payload.channelName}`,
|
||||
})
|
||||
.then((notifications) => {
|
||||
for (const notification of notifications) {
|
||||
|
@ -137,7 +137,7 @@ function showNotification(event, payload) {
|
|||
}
|
||||
|
||||
return self.registration.showNotification(payload.title, {
|
||||
tag: `chan-${payload.chanId}`,
|
||||
tag: `${payload.networkHost}/${payload.channelName}`,
|
||||
badge: "img/icon-alerted-black-transparent-bg-72x72px.png",
|
||||
icon: "img/icon-alerted-grey-bg-192x192px.png",
|
||||
body: payload.body,
|
||||
|
|
Loading…
Reference in a new issue