File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -136,19 +136,16 @@ class PushDeviceManager extends PerAccountStoreBase {
136136
137137    // TODO(#1764) if account.pushToken not null, skip? cf #322 
138138
139-     int ?  pushAccountId =  account.pushAccountId;
140-     Uint8List ?  pushKey =  account.pushKey;
141-     if  (pushAccountId ==  null ) {
142-       pushAccountId =  NotificationService .generatePushAccountId ();
143-       pushKey =  NotificationService .generatePushKey ();
139+     if  (token !=  account.pushToken) {
140+       // TODO(#1764) if old pushToken not null, maybe tell server to forget 
144141      await  updateAccount (AccountsCompanion (
145-         pushAccountId:  drift.Value (pushAccountId),
146-         pushKey:  drift.Value (pushKey),
142+         pushAccountId:  drift.Value (NotificationService .generatePushAccountId ()),
143+         pushKey:  drift.Value (NotificationService .generatePushKey ()),
144+         pushToken:  drift.Value (token),
147145      ));
148146    }
149-     if  (pushKey ==  null ) {
150-       throw  StateError ('Account missing pushKey while have pushAccountId' ); // TODO(log) 
151-     }
147+     final  pushAccountId =  account.pushAccountId! ;
148+     final  pushKey =  account.pushKey! ;
152149
153150    final  tokenKind =  switch  (defaultTargetPlatform) {
154151      TargetPlatform .android =>  PushTokenKind .fcm,
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments