@@ -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