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); }); }