@@ -310,6 +310,14 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
310
310
final GlobalStore _globalStore;
311
311
final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
312
312
313
+ UpdateMachine ? get updateMachine => _updateMachine;
314
+ UpdateMachine ? _updateMachine;
315
+ set updateMachine (UpdateMachine ? value) {
316
+ assert (_updateMachine == null );
317
+ assert (value != null );
318
+ _updateMachine = value;
319
+ }
320
+
313
321
bool get isLoading => _isLoading;
314
322
bool _isLoading = false ;
315
323
@visibleForTesting
@@ -452,6 +460,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
452
460
unreads.dispose ();
453
461
_messages.dispose ();
454
462
typingStatus.dispose ();
463
+ updateMachine? .dispose ();
455
464
super .dispose ();
456
465
}
457
466
@@ -729,7 +738,9 @@ class UpdateMachine {
729
738
// case of unauthenticated access to a web-public realm. We authenticated.
730
739
throw Exception ("bad initial snapshot: missing queueId" );
731
740
})(),
732
- lastEventId = initialSnapshot.lastEventId;
741
+ lastEventId = initialSnapshot.lastEventId {
742
+ store.updateMachine = this ;
743
+ }
733
744
734
745
/// Load the user's data from the server, and start an event queue going.
735
746
///
@@ -874,8 +885,8 @@ class UpdateMachine {
874
885
switch (e) {
875
886
case ZulipApiException (code: 'BAD_EVENT_QUEUE_ID' ):
876
887
assert (debugLog ('Lost event queue for $store . Replacing…' ));
888
+ // This disposes the store, which disposes this update machine.
877
889
await store._globalStore._reloadPerAccount (store.accountId);
878
- dispose ();
879
890
debugLog ('… Event queue replaced.' );
880
891
return ;
881
892
0 commit comments