Push notifications#183
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| useEffect(() => { | ||
| if (backendSubscriptionsError && isPushBackendUnavailableError(backendSubscriptionsError)) { | ||
| setPushUnavailable(true) | ||
| } | ||
| }, [backendSubscriptionsError]) | ||
|
|
||
| const isPushEnabled = useMemo(() => { | ||
| if (!browserSubscription || !backendSubscriptions) return false | ||
| return backendSubscriptions.some((sub) => sub.endpoint === browserSubscription.endpoint) |
There was a problem hiding this comment.
Generic query errors silently leave toggle in a misleading state
When getPushSubscriptions fails with a non-PushBackendUnavailableError (e.g. a 500, auth error, or network timeout), backendSubscriptions stays undefined, so isPushEnabled evaluates to false — the toggle appears "off". No pushError or pushUnavailable is set, so the UI shows no indication of failure, and the button remains enabled. A user who already has an active browser subscription then clicks the toggle to "re-enable" it: subscribeToBrowserPush returns the still-registered browser subscription (isExisting: true) and registerPushSubscription re-posts it to the backend, potentially creating a duplicate record. The missing branch is: any error that isn't a PushBackendUnavailableError should also surface to the user via setPushError.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| await unsubscribeFromBrowserPush() | ||
| if (backendSub) { | ||
| await deletePushSubscription(backendSub.id) | ||
| } | ||
| setBrowserSubscription(null) | ||
| await refetchBackendSubscriptions() |
There was a problem hiding this comment.
Stale browser subscription state after partial disable failure
setBrowserSubscription(null) is only called after both unsubscribeFromBrowserPush() and deletePushSubscription() succeed. If deletePushSubscription throws, the browser subscription is already gone from the push manager but browserSubscription state still holds the old object and backendSubscriptions hasn't been refetched — so isPushEnabled stays true and the toggle appears enabled despite push being broken. Moving setBrowserSubscription(null) to immediately after unsubscribeFromBrowserPush() returns keeps client state consistent regardless of what the backend call does.
No description provided.