aboutsummaryrefslogtreecommitdiff
path: root/src/sw.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2023-12-13 23:54:12 +0200
committerHenry Jameson <me@hjkos.com>2023-12-13 23:54:12 +0200
commit5ee8fc0aeadb59c6f78d0c8c8e725072ad9cdc54 (patch)
tree89fbacacdbc10bda8a03a9b354b6b934d971cbf7 /src/sw.js
parent99d04bed2bf96cade48c99bae8fcf154bd769998 (diff)
add setting to always show push notifications
Diffstat (limited to 'src/sw.js')
-rw-r--r--src/sw.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/sw.js b/src/sw.js
index 86f6e694..4ee7b9ff 100644
--- a/src/sw.js
+++ b/src/sw.js
@@ -29,6 +29,7 @@ const setSettings = async () => {
const locale = vuexState.config.interfaceLanguage || 'en'
i18n.locale = locale
const notificationsNativeArray = Object.entries(vuexState.config.notificationNative)
+ state.webPushAlwaysShowNotifications = vuexState.config.webPushAlwaysShowNotifications
state.allowedNotificationTypes = new Set(
notificationsNativeArray
@@ -62,7 +63,7 @@ const showPushNotification = async (event) => {
const activeClients = await getWindowClients()
await setSettings()
// Only show push notifications if all tabs/windows are closed
- if (activeClients.length === 0) {
+ if (state.webPushAlwaysShowNotifications || activeClients.length === 0) {
const data = event.data.json()
const url = `${self.registration.scope}api/v1/notifications/${data.notification_id}`
@@ -72,7 +73,7 @@ const showPushNotification = async (event) => {
const res = prepareNotificationObject(parsedNotification, i18n)
- if (state.allowedNotificationTypes.has(parsedNotification.type)) {
+ if (state.webPushAlwaysShowNotifications || state.allowedNotificationTypes.has(parsedNotification.type)) {
return self.registration.showNotification(res.title, res)
}
}