@@ -791,14 +791,13 @@ class UpdateMachine {
791791  UpdateMachine .fromInitialSnapshot ({
792792    required  this .store,
793793    required  InitialSnapshot  initialSnapshot,
794+     this .notificationTokenRegistrant,
794795  }) :  queueId =  initialSnapshot.queueId ??  (() {
795796         // The queueId is optional in the type, but should only be missing in the 
796797         // case of unauthenticated access to a web-public realm.  We authenticated. 
797798         throw  Exception ("bad initial snapshot: missing queueId" );
798799       })(),
799-        lastEventId =  initialSnapshot.lastEventId,
800-        _notificationTokenRegistrant =  NotificationTokenRegistrant (
801-          connection:  store.connection) {
800+        lastEventId =  initialSnapshot.lastEventId {
802801    store.updateMachine =  this ;
803802  }
804803
@@ -831,8 +830,12 @@ class UpdateMachine {
831830      connection:  connection,
832831      initialSnapshot:  initialSnapshot,
833832    );
833+     final  notificationTokenRegistrant =  NotificationTokenRegistrant (
834+       connection:  connection);
834835    final  updateMachine =  UpdateMachine .fromInitialSnapshot (
835-       store:  store, initialSnapshot:  initialSnapshot);
836+       store:  store, initialSnapshot:  initialSnapshot,
837+       notificationTokenRegistrant:  notificationTokenRegistrant,
838+     );
836839    updateMachine.poll ();
837840    if  (initialSnapshot.serverEmojiDataUrl !=  null ) {
838841      // TODO(server-6): If the server is ancient, just skip trying to have 
@@ -842,7 +845,7 @@ class UpdateMachine {
842845    }
843846    // TODO do [NotificationTokenRegistrant.start] before registerQueue: 
844847    //   https://github.com/zulip/zulip-flutter/pull/325#discussion_r1365982807 
845-     unawaited (updateMachine._notificationTokenRegistrant .start ());
848+     unawaited (notificationTokenRegistrant .start ());
846849    return  updateMachine;
847850  }
848851
@@ -1049,7 +1052,7 @@ class UpdateMachine {
10491052    }
10501053  }
10511054
1052-   final  NotificationTokenRegistrant  _notificationTokenRegistrant ;
1055+   final  NotificationTokenRegistrant ?  notificationTokenRegistrant ;
10531056
10541057  /// Cleans up resources and tells the instance not to make new API requests. 
10551058  /// 
@@ -1061,7 +1064,7 @@ class UpdateMachine {
10611064  /// requests to error. [PerAccountStore.dispose]  does that. 
10621065void  dispose () {
10631066    assert (! _disposed);
1064-     _notificationTokenRegistrant .dispose ();
1067+     notificationTokenRegistrant ? .dispose ();
10651068    _disposed =  true ;
10661069  }
10671070
0 commit comments