Skip to content

Commit 5e7d2f5

Browse files
committed
store: Add nullable [PerAccountStore.updateMachine]; dispose in [dispose]
1 parent a73e929 commit 5e7d2f5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/model/store.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
310310
final GlobalStore _globalStore;
311311
final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
312312

313+
UpdateMachine? get updateMachine => _updateMachine;
314+
UpdateMachine? _updateMachine;
315+
set updateMachine(UpdateMachine? value) {
316+
assert(_updateMachine == null);
317+
_updateMachine = value;
318+
}
319+
313320
bool get isLoading => _isLoading;
314321
bool _isLoading = false;
315322
@visibleForTesting
@@ -452,6 +459,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
452459
unreads.dispose();
453460
_messages.dispose();
454461
typingStatus.dispose();
462+
updateMachine?.dispose(); // TODO is updateMachine ever null except in tests?
455463
super.dispose();
456464
}
457465

@@ -729,7 +737,9 @@ class UpdateMachine {
729737
// case of unauthenticated access to a web-public realm. We authenticated.
730738
throw Exception("bad initial snapshot: missing queueId");
731739
})(),
732-
lastEventId = initialSnapshot.lastEventId;
740+
lastEventId = initialSnapshot.lastEventId {
741+
store.updateMachine = this;
742+
}
733743

734744
/// Load the user's data from the server, and start an event queue going.
735745
///

0 commit comments

Comments
 (0)