diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/service-worker.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/service-worker.ts b/src/service-worker.ts index 4799a492..18c839b1 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -114,8 +114,7 @@ sw.addEventListener('push', async (event: PushEvent) => { new Date().getTime()) ) { await database.users.update(user.id, { lastNotificationID: recentNotifications[0].id }); - - sw.registration.showNotification('due.moe', { + await sw.registration.showNotification('due.moe', { body: `${recentNotifications[0].user.name}${recentNotifications[0].context}`, icon: recentNotifications[0].user.avatar.large || '/favicon-196x196.png', // Ref. https://stackoverflow.com/a/50805868/14452787 @@ -129,18 +128,18 @@ sw.addEventListener('push', async (event: PushEvent) => { } if (navigator.userAgent.includes('Chrome')) { - sw.registration.showNotification('due.moe', { + await sw.registration.showNotification('due.moe', { body: 'No new notifications', icon: '/favicon-196x196.png', tag: 'notification-1' }); // Ref. https://github.com/firebase/quickstart-js/issues/126#issuecomment-504081087 - new Promise((resolve) => { + await new Promise((resolve) => { (resolve as unknown as () => void)(); setTimeout( - () => - sw.registration + async () => + await sw.registration .getNotifications() .then((notifications) => notifications.forEach((notification) => notification.close()) |