瀏覽代碼

Fix state transitions when restoring a session (#105)

* Update connection buildup state in digest loop
* Don't show unlock screen in 'waiting' state

When scanning the QR code, the scan screen must stay even when in
'waiting' state.

In contrast, after entering a password, the unlock screen should
disappear immediately.
Danilo Bargen 8 年之前
父節點
當前提交
9ec4731daa
共有 4 個文件被更改,包括 21 次插入4 次删除
  1. 1 1
      src/partials/welcome.html
  2. 3 1
      src/partials/welcome.ts
  3. 3 1
      src/services/webclient.ts
  4. 14 1
      src/threema.d.ts

+ 1 - 1
src/partials/welcome.html

@@ -21,7 +21,7 @@
             </div>
         </div>
 
-        <div ng-if="(ctrl.state === 'connecting' || ctrl.state === 'waiting') && ctrl.mode === 'unlock'" class="unlock">
+        <div ng-if="ctrl.state === 'connecting' && ctrl.mode === 'unlock'" class="unlock">
             <h2 class="instructions" translate>welcome.PLEASE_UNLOCK</h2>
             <div class="password-entry">
                 <label>

+ 3 - 1
src/partials/welcome.ts

@@ -367,8 +367,8 @@ class WelcomeController {
      * It must be initialized before calling this method.
      */
     private start() {
-        // Start
         this.webClientService.start().then(
+            // If connection buildup is done...
             () => {
                 // Pass password to webclient service
                 this.webClientService.setPassword(this.password);
@@ -379,6 +379,8 @@ class WelcomeController {
                 // Redirect to home
                 this.$timeout(() => this.$state.go('messenger.home'), WelcomeController.REDIRECT_DELAY);
             },
+
+            // If an error occurs...
             (error) => {
                 this.$log.error('Error state:', error);
                 // TODO: should probably show an error message instead

+ 3 - 1
src/services/webclient.ts

@@ -494,7 +494,9 @@ export class WebClientService implements threema.WebClientService {
                 .catch(() => this.$log.warn('Could not notify app!'))
                 .then(() => {
                     this.$log.debug('Requested app wakeup');
-                    this.state.updateConnectionBuildupState('push');
+                    this.$rootScope.$apply(() => {
+                        this.state.updateConnectionBuildupState('push');
+                    });
                 });
         } else if (this.trustedKeyStore.hasTrustedKey()) {
             this.$log.debug('Push service not available');

+ 14 - 1
src/threema.d.ts

@@ -233,8 +233,21 @@ declare namespace threema {
 
     /**
      * Connection state in the welcome dialog.
+     *
+     * States:
+     *
+     * - new: Initial state
+     * - connecting: Connecting to signaling server
+     * - push: When trying to reconnect, waiting for push notification to arrive
+     * - manual_start: When trying to reconnect, waiting for manual session start
+     * - waiting: Waiting for new-responder message from signaling server
+     * - peer_handshake: Doing SaltyRTC handshake with the peer
+     * - loading: Loading initial data
+     * - done: Initial loading is finished
+     * - closed: Connection is closed
+     *
      */
-    type ConnectionBuildupState = 'new' | 'push' | 'manual_start' | 'connecting' | 'waiting'
+    type ConnectionBuildupState = 'new' | 'connecting' | 'push' | 'manual_start' | 'waiting'
         | 'peer_handshake' | 'loading' | 'done' | 'closed';
 
     /**