Skip to content

fix(notifications): prevent push dropout after SW restart#823

Closed
Just-Insane wants to merge 1 commit into
SableClient:devfrom
Just-Insane:fix/notification-dropout
Closed

fix(notifications): prevent push dropout after SW restart#823
Just-Insane wants to merge 1 commit into
SableClient:devfrom
Just-Insane:fix/notification-dropout

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

@Just-Insane Just-Insane commented May 14, 2026

Closing — consolidated into fix/push-sw (#828).

Two root causes for notifications stopping after a while:

1. sw.ts hasVisibleClient used OR logic (appIsVisible || matchAll visible):
   On iOS the SW is killed between pushes so appIsVisible resets to false
   on restart.  With OR logic, a stale matchAll() result with
   visibilityState='visible' still set hasVisibleClient=true, silently
   suppressing every notification after the first.

   Fix: switch to AND logic so BOTH appIsVisible AND a visible client are
   required to suppress.  A cold-start SW (appIsVisible=false) never
   suppresses, regardless of stale matchAll() data.

2. useAppVisibility.ts was passing isMobile as keepEnabledWhenVisible,
   meaning on desktop the pusher was deleted from the homeserver whenever
   the tab was visible.  If the async re-enable in enablePushNotifications
   didn't complete before the page was torn down, the homeserver was left
   with no pusher — so no more push notifications until a manual
   background/foreground cycle.

   Fix: always pass true for keepEnabledWhenVisible so the pusher stays
   registered permanently.  The SW's hasVisibleClient check handles
   OS-notification suppression in the foreground; the homeserver never
   needs to be without a pusher.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant