summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2018-01-09 14:22:20 +0100
committerErik Larkö <erik@mullvad.net>2018-01-09 14:22:20 +0100
commitb64639845d86d0f25fadbda4173644af50d912e1 (patch)
tree2c996a62dc0c6fbd39204bd4c5b8b899d3d39a14 /app/lib
parente7defa271e70fe7a145daedb17597115d2ca52d4 (diff)
parent2707a2919eb4cc087695dbca12d5d6c74975c30a (diff)
downloadmullvadvpn-b64639845d86d0f25fadbda4173644af50d912e1.tar.xz
mullvadvpn-b64639845d86d0f25fadbda4173644af50d912e1.zip
Merge branch 'read-state-on-start'
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/backend.js34
1 files changed, 23 insertions, 11 deletions
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) {