Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Dialogues/Friends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
tokensRef.on('value', tokensSubscriber);

// TODO: Disable? After 3 failed attempts, permission = 'blocked'
if (window.Notification?.permission === 'default')
// Also re-save on 'granted' in case the service worker was refreshed (e.g. version reset)
if (window.Notification?.permission !== 'denied')
tokensRef.once('value', snapshot => snapshot.child(token).exists() || saveFcmToken())
Comment on lines +108 to 110
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getFcmToken() can resolve with a falsy token (e.g. null) when Messaging can't provide one yet. In that case snapshot.child(token) will throw and break this effect. Guard against a missing token before calling .child(...) (and decide whether you want to call saveFcmToken() when token is missing).

Copilot uses AI. Check for mistakes.
})
.catch(error => {
Expand Down Expand Up @@ -208,7 +209,7 @@
case 'denied':
alert(t('notificationsDenied'));
break;
// @ts-expect-error

Check failure on line 212 in src/Dialogues/Friends.tsx

View workflow job for this annotation

GitHub Actions / test

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer
case 'granted':
if (hasFcmToken) {
const confirmMessage = t('disableNotificationsConfirm');
Expand All @@ -220,7 +221,7 @@
break;
}
// fall-through
case 'default':

Check failure on line 224 in src/Dialogues/Friends.tsx

View workflow job for this annotation

GitHub Actions / test

Expected a 'break' statement before 'case'

setNotificationStatus('processing');
fcmTokenRef.current = await saveFcmToken();
Expand Down
Loading