diff options
| author | Erik Larkö <erik@mullvad.net> | 2018-01-09 14:22:20 +0100 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2018-01-09 14:22:20 +0100 |
| commit | b64639845d86d0f25fadbda4173644af50d912e1 (patch) | |
| tree | 2c996a62dc0c6fbd39204bd4c5b8b899d3d39a14 | |
| parent | e7defa271e70fe7a145daedb17597115d2ca52d4 (diff) | |
| parent | 2707a2919eb4cc087695dbca12d5d6c74975c30a (diff) | |
| download | mullvadvpn-b64639845d86d0f25fadbda4173644af50d912e1.tar.xz mullvadvpn-b64639845d86d0f25fadbda4173644af50d912e1.zip | |
Merge branch 'read-state-on-start'
| -rw-r--r-- | app/app.js | 1 | ||||
| -rw-r--r-- | app/lib/backend.js | 34 |
2 files changed, 24 insertions, 11 deletions
diff --git a/app/app.js b/app/app.js index e84a577223..3a9d6c0294 100644 --- a/app/app.js +++ b/app/app.js @@ -28,6 +28,7 @@ ipcRenderer.on('backend-info', async (_event, args) => { try { await backend.autologin(); await backend.fetchRelaySettings(); + await backend.fetchSecurityState(); await backend.connect(); } catch (e) { if(e instanceof BackendError) { diff --git a/app/lib/backend.js b/app/lib/backend.js index da87deced4..62babdf4b6 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -421,6 +421,14 @@ export class Backend { ); } + async fetchSecurityState() { + await this._ensureAuthenticated(); + + const securityState = await this._ipc.getState(); + const connectionState = this._securityStateToConnectionState(securityState); + this._dispatchConnectionState(connectionState); + } + /** * Start reachability monitoring for online/offline detection * This is currently done via HTML5 APIs but will be replaced later @@ -452,17 +460,7 @@ export class Backend { log.debug('Got new state from backend', newState); const newStatus = this._securityStateToConnectionState(newState); - switch(newStatus) { - case 'connecting': - this._store.dispatch(connectionActions.connecting()); - break; - case 'connected': - this._store.dispatch(connectionActions.connected()); - break; - case 'disconnected': - this._store.dispatch(connectionActions.disconnected()); - break; - } + this._dispatchConnectionState(newStatus); this.sync(); }); } @@ -478,6 +476,20 @@ export class Backend { throw new Error('Unsupported state/target state combination: ' + JSON.stringify(backendState)); } + _dispatchConnectionState(connectionState: ConnectionState) { + switch(connectionState) { + case 'connecting': + this._store.dispatch(connectionActions.connecting()); + break; + case 'connected': + this._store.dispatch(connectionActions.connected()); + break; + case 'disconnected': + this._store.dispatch(connectionActions.disconnected()); + break; + } + } + _ensureAuthenticated() { const credentials = this._credentials; if(credentials) { |
