Skip to content

Commit

Permalink
Use return await in service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Dec 28, 2023
1 parent 385b07a commit ceb6863
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sw/eventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ export function onPush (sw) {
if (!payload) return
const { tag } = payload.options
event.waitUntil((async () => {
// TODO fix silent push here
if (skipNotification(payload)) return
if (immediatelyShowNotification(payload)) {
setAppBadge(sw, ++activeCount)
return sw.registration.showNotification(payload.title, payload.options)
return await sw.registration.showNotification(payload.title, payload.options)
}

// fetch existing notifications with same tag
Expand All @@ -45,11 +46,11 @@ export function onPush (sw) {
if (notifications.length === 0) {
// incoming notification is first notification with this tag
setAppBadge(sw, ++activeCount)
return sw.registration.showNotification(payload.title, payload.options)
return await sw.registration.showNotification(payload.title, payload.options)
}

const currentNotification = notifications[0]
return mergeAndShowNotification(sw, payload, currentNotification)
return await mergeAndShowNotification(sw, payload, currentNotification)
})())
}
}
Expand Down

0 comments on commit ceb6863

Please sign in to comment.