summaryrefslogtreecommitdiffhomepage
path: root/app/lib
diff options
context:
space:
mode:
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) {