We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 432b436 commit e1e3a24Copy full SHA for e1e3a24
sw/eventListener.js
@@ -242,17 +242,13 @@ export function onMessage (sw) {
242
return event.waitUntil(storage.removeItem('subscription'))
243
}
244
if (event.data.action === CLEAR_NOTIFICATIONS) {
245
- return event.waitUntil((async () => {
246
- let notifications = []
247
- try {
248
- notifications = await sw.registration.getNotifications()
249
- } catch (err) {
250
- console.error('failed to get notifications')
251
- }
+ const promises = []
+ promises.push(sw.registration.getNotifications().then((notifications) => {
252
notifications.forEach(notification => notification.close())
253
- activeCount = 0
254
- return await clearAppBadge(sw)
255
- })())
+ }))
+ activeCount = 0
+ promises.push(clearAppBadge(sw))
+ event.waitUntil(Promise.all(promises))
256
257
258
0 commit comments