From 3afbc3b6b7e197859ee0ebda2ad049b011d2d3cb Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 29 Oct 2026 11:22:50 +0100 Subject: [PATCH 1/2] refactor(notifications): extract web push callbacks into methods Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Maksim Sukharev --- src/NotificationsApp.vue | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/NotificationsApp.vue b/src/NotificationsApp.vue index cca0a8e90..a28ff1f44 100644 --- a/src/NotificationsApp.vue +++ b/src/NotificationsApp.vue @@ -286,9 +286,6 @@ export default { // set the polling interval after checking web push status // if web push may be configured if (webPushForBrowsersEnabled && this.webNotificationsGranted === true) { - // We don't fetch on push if notify_push is enabled, to avoid concurrency fetch. - // We could do the other way: fallback to notify_push only if we don't have - // web push if (document.readyState === 'complete') { this._setWebPush() } else { @@ -321,25 +318,27 @@ export default { }, async _setWebPush() { - return setWebPush( - // onActivated= - (hasWebPush) => { - if (hasWebPush) { - console.debug('Has web push, slowing polling to 15 minutes') - this.pollIntervalBase = 15 * 60 * 1000 - } - // Set polling interval for the default or new value - this._setPollingInterval(this.pollIntervalBase) - }, - // onPush= - () => { - if (!this.hasNotifyPush) { - this._fetchAfterWebPush() - } else { - console.debug('Has notify_push, no need to fetch from web push.') - } - }, - ) + return setWebPush(this._onWebPushActivated, this._onWebPush) + }, + + _onWebPushActivated(hasWebPush) { + if (hasWebPush) { + console.debug('Has web push, slowing polling to 15 minutes') + this.pollIntervalBase = 15 * 60 * 1000 + } + // Set polling interval for the default or new value + this._setPollingInterval(this.pollIntervalBase) + }, + + _onWebPush() { + // We don't fetch on push if notify_push is enabled, to avoid concurrency fetch. + // We could do the other way: fallback to notify_push only if we don't have + // web push + if (!this.hasNotifyPush) { + this._fetchAfterWebPush() + } else { + console.debug('Has notify_push, no need to fetch from web push.') + } }, async onOpen() { From d90cdace5ff54c8bd34f357138d33dfbbbb10ccf Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 29 Oct 2026 11:23:02 +0100 Subject: [PATCH 2/2] perf(notifications): sync tabs with Web Locks and BroadcastChannel Only one tab per browser polls, handles notify_push and registers web push. Other tabs receive the data over a BroadcastChannel and do not fetch on load. Without Web Locks (insecure context) every tab polls on its own. Notification data is no longer cached in localStorage. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Maksim Sukharev --- src/NotificationsApp.vue | 102 ++++++++++++++++----------- src/composables/useTabSync.js | 75 ++++++++++++++++++++ src/main.js | 6 ++ src/services/notificationsService.js | 71 +++---------------- src/services/webPushService.js | 21 ++++++ 5 files changed, 171 insertions(+), 104 deletions(-) create mode 100644 src/composables/useTabSync.js diff --git a/src/NotificationsApp.vue b/src/NotificationsApp.vue index a28ff1f44..87c7dd4e8 100644 --- a/src/NotificationsApp.vue +++ b/src/NotificationsApp.vue @@ -97,7 +97,7 @@