Skip to content

Commit 937456f

Browse files
committed
wip eh, treat missing as empty
1 parent c93942f commit 937456f

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

lib/model/push_device.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'store.dart';
1313
class PushDeviceManager extends PerAccountStoreBase {
1414
PushDeviceManager({
1515
required super.core,
16-
required Map<int, PushDeviceEntry>? pushDevices,
16+
required Map<int, PushDeviceEntry> pushDevices,
1717
}) : _registrant = PushTokenRegistrant(core: core),
1818
_pushDevices = pushDevices;
1919

@@ -44,19 +44,13 @@ class PushDeviceManager extends PerAccountStoreBase {
4444
/// For docs, search for "push_device"
4545
/// in <https://zulip.com/api/register-queue>.
4646
///
47-
/// Null if the server was old and did not provide such a map.
48-
// TODO(server-11) make non-nullable when [InitialSnapshot.pushDevices] is
49-
late Map<int, PushDeviceEntry>? pushDevices =
50-
_pushDevices == null ? null : UnmodifiableMapView(_pushDevices);
51-
final Map<int, PushDeviceEntry>? _pushDevices;
47+
/// An absent map in [InitialSnapshot] (from an old server) is treated
48+
/// as empty, since a server without this feature has none of these records.
49+
// TODO(server-11) simplify doc re an absent map
50+
late Map<int, PushDeviceEntry> pushDevices = UnmodifiableMapView(_pushDevices);
51+
final Map<int, PushDeviceEntry> _pushDevices;
5252

5353
void handlePushDeviceEvent(PushDeviceEvent event) {
54-
if (_pushDevices == null) {
55-
// TODO(log)... but in principle this is possible if the server was
56-
// upgraded, gaining support for this feature,
57-
// in the life of the event queue.
58-
return;
59-
}
6054
final pushAccountId = int.tryParse(event.pushAccountId, radix: 10);
6155
if (pushAccountId == null) return; // TODO(log); TODO(#1764) push this to API parser
6256
_pushDevices[pushAccountId] = event.data;

lib/model/store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class PerAccountStore extends PerAccountStoreBase with
530530
allRealmEmoji: initialSnapshot.realmEmoji),
531531
userSettings: initialSnapshot.userSettings,
532532
pushDevices: PushDeviceManager(core: core,
533-
pushDevices: initialSnapshot.pushDevices),
533+
pushDevices: initialSnapshot.pushDevices ?? {}),
534534
savedSnippets: SavedSnippetStoreImpl(core: core,
535535
savedSnippets: initialSnapshot.savedSnippets ?? []),
536536
typingNotifier: TypingNotifier(realm: realm),

0 commit comments

Comments
 (0)