diff options
| -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) { |
