Skip to content

Commit b492759

Browse files
committed
wip clarify todo for 322
1 parent f954fd5 commit b492759

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/model/push_device.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,25 @@ class PushDeviceManager extends PerAccountStoreBase {
134134
return _legacyRegisterToken(token);
135135
}
136136

137-
// TODO(#1764) if account.pushToken not null, skip? cf #322
138-
139137
if (token != account.pushToken) {
140138
// TODO(#1764) if old pushToken not null, maybe tell server to forget
141139
await updateAccount(AccountsCompanion(
142140
pushAccountId: drift.Value(NotificationService.generatePushAccountId()),
143141
pushKey: drift.Value(NotificationService.generatePushKey()),
144142
pushToken: drift.Value(token),
145143
));
144+
} else {
145+
// We've already attempted registering this token, perhaps succeeded.
146+
// For now, just go ahead.
147+
// TODO(#1764)/TODO(#322) if past registration succeeded, and recently,
148+
// then skip doing it again.
149+
}
150+
151+
final pushAccountId = account.pushAccountId;
152+
final pushKey = account.pushKey;
153+
if (pushAccountId == null || pushKey == null) {
154+
throw StateError('Account missing pushAccountId and/or pushKey, while has pushToken'); // TODO(log)
146155
}
147-
final pushAccountId = account.pushAccountId!;
148-
final pushKey = account.pushKey!;
149156

150157
final tokenKind = switch (defaultTargetPlatform) {
151158
TargetPlatform.android => PushTokenKind.fcm,

0 commit comments

Comments
 (0)