From a2daac6dd2d45242b8f2d8553e5d87f902866ab1 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 13 Dec 2023 22:14:00 +0200 Subject: [PATCH] test shit --- src/services/sw/sw.js | 2 +- src/sw.js | 19 +------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js index 98dc7294c..4516c813b 100644 --- a/src/services/sw/sw.js +++ b/src/services/sw/sw.js @@ -28,7 +28,7 @@ function subscribePush (registration, isEnabled, vapidPublicKey) { if (!vapidPublicKey) return Promise.reject(new Error('VAPID public key is not found')) const subscribeOptions = { - userVisibleOnly: false, + userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(vapidPublicKey) } return registration.pushManager.subscribe(subscribeOptions) diff --git a/src/sw.js b/src/sw.js index 86f6e6949..9d1896c77 100644 --- a/src/sw.js +++ b/src/sw.js @@ -59,24 +59,7 @@ const setSettings = async () => { } const showPushNotification = async (event) => { - const activeClients = await getWindowClients() - await setSettings() - // Only show push notifications if all tabs/windows are closed - if (activeClients.length === 0) { - const data = event.data.json() - - const url = `${self.registration.scope}api/v1/notifications/${data.notification_id}` - const notification = await fetch(url, { headers: { Authorization: 'Bearer ' + data.access_token } }) - const notificationJson = await notification.json() - const parsedNotification = parseNotification(notificationJson) - - const res = prepareNotificationObject(parsedNotification, i18n) - - if (state.allowedNotificationTypes.has(parsedNotification.type)) { - return self.registration.showNotification(res.title, res) - } - } - return Promise.resolve() + return self.registration.showNotification(res.title, res) } self.addEventListener('push', async (event) => {