Skip to content

Commit 389213a

Browse files
committed
store [nfc]: Move queueId to PerAccountStore
This is an NFC because UpdateMachine would have thrown (before this change) when the null-check is not on PerAccountStore. This queueId will later be used for local-echoing.
1 parent badf3ed commit 389213a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/model/store.dart

+12-7
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,19 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
333333
connection ??= globalStore.apiConnectionFromAccount(account);
334334
assert(connection.zulipFeatureLevel == account.zulipFeatureLevel);
335335

336+
final queueId = initialSnapshot.queueId;
337+
if (queueId == null) {
338+
// The queueId is optional in the type, but should only be missing in the
339+
// case of unauthenticated access to a web-public realm. We authenticated.
340+
throw Exception("bad initial snapshot: missing queueId");
341+
}
342+
336343
final realmUrl = account.realmUrl;
337344
final channels = ChannelStoreImpl(initialSnapshot: initialSnapshot);
338345
return PerAccountStore._(
339346
globalStore: globalStore,
340347
connection: connection,
348+
queueId: queueId,
341349
realmUrl: realmUrl,
342350
realmWildcardMentionPolicy: initialSnapshot.realmWildcardMentionPolicy,
343351
realmMandatoryTopics: initialSnapshot.realmMandatoryTopics,
@@ -381,6 +389,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
381389
PerAccountStore._({
382390
required GlobalStore globalStore,
383391
required this.connection,
392+
required this.queueId,
384393
required this.realmUrl,
385394
required this.realmWildcardMentionPolicy,
386395
required this.realmMandatoryTopics,
@@ -420,6 +429,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
420429
final GlobalStore _globalStore;
421430
final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
422431

432+
String queueId;
423433
UpdateMachine? get updateMachine => _updateMachine;
424434
UpdateMachine? _updateMachine;
425435
set updateMachine(UpdateMachine? value) {
@@ -997,12 +1007,7 @@ class UpdateMachine {
9971007
UpdateMachine.fromInitialSnapshot({
9981008
required this.store,
9991009
required InitialSnapshot initialSnapshot,
1000-
}) : queueId = initialSnapshot.queueId ?? (() {
1001-
// The queueId is optional in the type, but should only be missing in the
1002-
// case of unauthenticated access to a web-public realm. We authenticated.
1003-
throw Exception("bad initial snapshot: missing queueId");
1004-
})(),
1005-
lastEventId = initialSnapshot.lastEventId {
1010+
}) : lastEventId = initialSnapshot.lastEventId {
10061011
store.updateMachine = this;
10071012
}
10081013

@@ -1067,8 +1072,8 @@ class UpdateMachine {
10671072
return updateMachine;
10681073
}
10691074

1075+
String get queueId => store.queueId;
10701076
final PerAccountStore store;
1071-
final String queueId;
10721077
int lastEventId;
10731078

10741079
bool _disposed = false;

0 commit comments

Comments
 (0)