Skip to content

Commit 9087c62

Browse files
committed
notifs: Split out NotificationProblem.TokenUnknown from TokenNotAcked
Now the two enum values TokenNotAcked and TokenUnknown together cover the conditions that were previously covered by just TokenNotAcked, and with no overlap. TokenUnknown will be chosen instead of TokenNotAcked when we haven't yet gotten a token from the platform.
1 parent dcbbacc commit 9087c62

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/settings/NotifTroubleshootingScreen.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ function useNativeState() {
123123
*/
124124
export enum NotificationProblem {
125125
TokenNotAcked = 0,
126-
SystemSettingsDisabled = 1,
127-
GooglePlayServicesNotAvailable = 2,
128-
ServerHasNotEnabled = 3,
126+
TokenUnknown = 1,
127+
SystemSettingsDisabled = 2,
128+
GooglePlayServicesNotAvailable = 3,
129+
ServerHasNotEnabled = 4,
129130

130131
// TODO: more, such as:
131132
// - Can't reach the server (ideally after #5615, to be less buggy)
@@ -244,7 +245,9 @@ export function useNotificationReportsByIdentityKey(): Map<string, NotificationR
244245
if (serverData && !serverData.pushNotificationsEnabled) {
245246
problems.push(NotificationProblem.ServerHasNotEnabled);
246247
}
247-
if (ackedPushToken == null || pushToken !== ackedPushToken) {
248+
if (pushToken == null) {
249+
problems.push(NotificationProblem.TokenUnknown);
250+
} else if (pushToken !== ackedPushToken) {
248251
problems.push(NotificationProblem.TokenNotAcked);
249252
}
250253
}
@@ -465,11 +468,18 @@ export default function NotifTroubleshootingScreen(props: Props): React.Node {
465468

466469
case NotificationProblem.TokenNotAcked: {
467470
// TODO: Could offer:
468-
// - Re-request the device token from the platform (#5329 may be
469-
// an obstacle), and show if a/the request hasn't completed
470471
// - Re-request registering token with server, and show if a/the
471472
// request hasn't completed
472473
alerts.push(genericAlert);
474+
break;
475+
}
476+
477+
case NotificationProblem.TokenUnknown: {
478+
// TODO: Could offer:
479+
// - Re-request the device token from the platform (#5329 may be
480+
// an obstacle), and show if a/the request hasn't completed
481+
alerts.push(genericAlert);
482+
break;
473483
}
474484
}
475485
});

src/settings/NotificationsScreen.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function systemSettingsWarning(problem): LocalizableText | null {
3434
return 'Notifications are disabled.';
3535
case NotificationProblem.GooglePlayServicesNotAvailable:
3636
case NotificationProblem.TokenNotAcked:
37+
case NotificationProblem.TokenUnknown:
3738
case NotificationProblem.ServerHasNotEnabled:
3839
// We can't ask the user to fix this in system notification settings.
3940
return null;

0 commit comments

Comments
 (0)