From bcdf336242307a149ab295a760d7b8851063f446 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 13 Dec 2023 18:36:16 +0200 Subject: [PATCH 1/5] try to fix the "website updated in background" notification --- src/sw.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sw.js b/src/sw.js index 469291b97..86f6e6949 100644 --- a/src/sw.js +++ b/src/sw.js @@ -73,13 +73,16 @@ const showPushNotification = async (event) => { const res = prepareNotificationObject(parsedNotification, i18n) if (state.allowedNotificationTypes.has(parsedNotification.type)) { - self.registration.showNotification(res.title, res) + return self.registration.showNotification(res.title, res) } } + return Promise.resolve() } self.addEventListener('push', async (event) => { if (event.data) { + // Supposedly, we HAVE to return a promise inside waitUntil otherwise it will + // show (extra) notification that website is updated in background event.waitUntil(showPushNotification(event)) } }) From 4e8bb80dbd0ff5993f5613c6cbdfe757af0d0807 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 13 Dec 2023 20:37:40 +0200 Subject: [PATCH 2/5] fix incorrect title + add counter --- src/components/mobile_nav/mobile_nav.js | 6 ++++++ src/components/mobile_nav/mobile_nav.vue | 10 ++++++++-- src/i18n/en.json | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js index 0cd679904..ec9aeed0a 100644 --- a/src/components/mobile_nav/mobile_nav.js +++ b/src/components/mobile_nav/mobile_nav.js @@ -57,6 +57,12 @@ const MobileNav = { unseenNotificationsCount () { return this.unseenNotifications.length + countExtraNotifications(this.$store) }, + unseenCount () { + return this.unseenNotifications.length + }, + unseenCountBadgeText () { + return `${this.unseenCount ? this.unseenCount : ''}${this.extraNotificationsCount ? '*' : ''}` + }, hideSitename () { return this.$store.state.instance.hideSitename }, sitename () { return this.$store.state.instance.name }, isChat () { diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index ecd8290a0..f20a509d5 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -50,7 +50,13 @@ @touchmove.stop="notificationsTouchMove" >
- {{ $t('notifications.notifications') }} + + {{ $t('notifications.notifications') }} + {{ unseenCountBadgeText }} +