From d0075eeddf668fa6f7f98b0111e97aedf5393b86 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Aug 2026 09:10:43 +0200 Subject: [PATCH] rest notification: service-worker path for Android, use existing string --- frontend/src/store/useUI.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/store/useUI.js b/frontend/src/store/useUI.js index 0330ee7..d1a121a 100644 --- a/frontend/src/store/useUI.js +++ b/frontend/src/store/useUI.js @@ -33,7 +33,14 @@ const maybeRestNotification = async () => { if (!document.hidden && document.visibilityState !== 'hidden') return if (Notification.permission !== 'granted' && !(await requestRestNotificationPermission())) return try { - new Notification(t('Rest over'), { body: t('Rest over — next set!') }) + // Android Chrome forbids the Notification constructor (Illegal constructor) - the + // service-worker registration path is the one that actually pops there. + const reg = await navigator.serviceWorker?.getRegistration?.() + if (reg?.showNotification) { + reg.showNotification(t('Rest over — next set!'), { body: t('Rest over — next set!') }) + return + } + new Notification(t('Rest over — next set!'), { body: t('Rest over — next set!') }) } catch { // Intentionally ignore: notification APIs vary by browser and policy in edge cases. }