This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: only set notificationToken after successful backend registration

Greptile flagged that enableWebNotifications committed the subscription
token to the store before the POST /api/notification call, and never
checked the response status. A network hiccup or server error after
PushManager.subscribe() left the toggle showing "on" while the server
had no subscription row — the user believed they were subscribed when
they weren't.

Now the token is only set after a confirmed successful POST (res.ok
check), mirroring the disableWebNotifications fix from the earlier
review pass. On failure the catch block returns "denied" so the toggle
stays honest and the user can retry.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

+8 -2
+8 -2
js/app/store/slices/platformSlice.ts
··· 108 108 applicationServerKey: urlBase64ToUint8Array(publicKey) as BufferSource, 109 109 }); 110 110 const subJSON = JSON.stringify(subscription); 111 - set({ notificationToken: subJSON }); 112 111 113 - // Register the subscription with the backend. 112 + // Register the subscription with the backend. Only commit the token to 113 + // the store after a confirmed successful POST — otherwise the toggle 114 + // shows "on" while the server has no subscription row, and the user 115 + // believes they're subscribed when they aren't. 114 116 const { oauthSession } = get(); 115 117 const body: { token: string; type: string; repoDID?: string } = { 116 118 token: subJSON, ··· 124 126 headers: { "content-type": "application/json" }, 125 127 body: JSON.stringify(body), 126 128 }); 129 + if (!res.ok) { 130 + throw new Error(`server registration failed: ${res.status}`); 131 + } 132 + set({ notificationToken: subJSON }); 127 133 console.log("web notification registration status:", res.status); 128 134 return permission; 129 135 } catch (e) {