瀏覽代碼

Don't reset state after push service init

Danilo Bargen 7 年之前
父節點
當前提交
c5bca54e78
共有 2 個文件被更改,包括 15 次插入10 次删除
  1. 14 10
      src/partials/welcome.ts
  2. 1 0
      src/services/webclient.ts

+ 14 - 10
src/partials/welcome.ts

@@ -302,14 +302,8 @@ class WelcomeController {
         // Set up the broadcast channel that checks whether we're already connected in another tab
         // Set up the broadcast channel that checks whether we're already connected in another tab
         this.setupBroadcastChannel(keyStore.publicKeyHex);
         this.setupBroadcastChannel(keyStore.publicKeyHex);
 
 
-        // Initialize push service
-        if (decrypted.pushToken !== null && decrypted.pushTokenType !== null) {
-            this.webClientService.updatePushToken(decrypted.pushToken, decrypted.pushTokenType);
-            this.pushService.init(decrypted.pushToken, decrypted.pushTokenType);
-        }
-
         // Reconnect
         // Reconnect
-        this.reconnect(keyStore, decrypted.peerPublicKey);
+        this.reconnect(keyStore, decrypted);
     }
     }
 
 
     /**
     /**
@@ -381,19 +375,29 @@ class WelcomeController {
     }
     }
 
 
     /**
     /**
-     * Reconnect using a specific keypair and peer public key.
+     * Reconnect using a specific keypair and the decrypted data from the trusted keystore.
      */
      */
-    private reconnect(keyStore: saltyrtc.KeyStore, peerTrustedKey: Uint8Array): void {
+    private reconnect(keyStore: saltyrtc.KeyStore, decrypted: threema.TrustedKeyStoreData): void {
+        // Reset state
         this.webClientService.stop({
         this.webClientService.stop({
             reason: DisconnectReason.SessionStopped,
             reason: DisconnectReason.SessionStopped,
             send: false,
             send: false,
             close: 'welcome',
             close: 'welcome',
         });
         });
+
+        // Initialize push service
+        if (decrypted.pushToken !== null && decrypted.pushTokenType !== null) {
+            this.webClientService.updatePushToken(decrypted.pushToken, decrypted.pushTokenType);
+            this.pushService.init(decrypted.pushToken, decrypted.pushTokenType);
+        }
+
+        // Initialize webclient service
         this.webClientService.init({
         this.webClientService.init({
             keyStore: keyStore,
             keyStore: keyStore,
-            peerTrustedKey: peerTrustedKey,
+            peerTrustedKey: decrypted.peerPublicKey,
             resume: false,
             resume: false,
         });
         });
+
         this.start();
         this.start();
     }
     }
 
 

+ 1 - 0
src/services/webclient.ts

@@ -1086,6 +1086,7 @@ export class WebClientService {
         // Clear stored data (trusted key, push token, etc) if deleting the session
         // Clear stored data (trusted key, push token, etc) if deleting the session
         if (remove) {
         if (remove) {
             this.trustedKeyStore.clearTrustedKey();
             this.trustedKeyStore.clearTrustedKey();
+            this.pushService.reset();
         }
         }
 
 
         // Invalidate and clear caches
         // Invalidate and clear caches