undo all that crap

This commit is contained in:
Henry Jameson 2023-12-13 22:35:19 +02:00
parent a3733eae60
commit b59b6c132d

View file

@ -59,19 +59,24 @@ const setSettings = async () => {
}
const showPushNotification = async (event) => {
// const activeClients = await getWindowClients()
const activeClients = await getWindowClients()
await setSettings()
// Only show push notifications if all tabs/windows are closed
const data = event.data.json()
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 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)
const res = prepareNotificationObject(parsedNotification, i18n)
return self.registration.showNotification(res.title, res)
if (state.allowedNotificationTypes.has(parsedNotification.type)) {
return self.registration.showNotification(res.title, res)
}
}
return Promise.resolve()
}
self.addEventListener('push', async (event) => {