From a9025e7c5957cd83e66d35a434586dd16d9af2d2 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 25 Jan 2022 13:30:00 +0000 Subject: [PATCH] fix --- .../sw/src/scripts/create-notification.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts index 674accc76a..6f158dc085 100644 --- a/packages/sw/src/scripts/create-notification.ts +++ b/packages/sw/src/scripts/create-notification.ts @@ -202,19 +202,21 @@ async function composeNotification(data } export async function createEmptyNotification() { - if (!swLang.i18n) swLang.fetchLocale(); - const i18n = await swLang.i18n as I18n; - const { t } = i18n; + return new Promise(async res => { + if (!swLang.i18n) swLang.fetchLocale(); + const i18n = await swLang.i18n as I18n; + const { t } = i18n; + + await self.registration.showNotification( + t('_notification.emptyPushNotificationMessage'), + { + silent: true, + tag: 'read_notification', + } + ); - await self.registration.showNotification( - t('_notification.emptyPushNotificationMessage'), - { - silent: true, - tag: 'read_notification', - } - ); + res(); - return new Promise(res => { setTimeout(async () => { for (const n of [ @@ -224,7 +226,6 @@ export async function createEmptyNotification() { ) { n.close(); } - res(); }, 1000); }); }