diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-03-31 15:55:34 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-04-04 12:00:01 +0200 |
| commit | d5385e0b7e66a75c3b4ed57fa000b0f03efebb39 (patch) | |
| tree | 5db4272147d2396782af24de940c7839185867b4 | |
| parent | 600414493597fb49357becdf2616e453f726dd19 (diff) | |
| download | mullvadvpn-d5385e0b7e66a75c3b4ed57fa000b0f03efebb39.tar.xz mullvadvpn-d5385e0b7e66a75c3b4ed57fa000b0f03efebb39.zip | |
Show launch view before receiving device config
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 4 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 6 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 5 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 1 |
4 files changed, 15 insertions, 1 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 6e3fde5ea0..b57591c4af 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -513,6 +513,10 @@ export class DaemonRpc { } } + public async updateDevice(): Promise<void> { + await this.callEmpty(this.client.updateDevice); + } + public async listDevices(accountToken: AccountToken): Promise<Array<IDevice>> { const response = await this.callString<grpcTypes.DeviceList>( this.client.listDevices, diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 4ab0cbdd93..a47fa699df 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -198,6 +198,7 @@ class ApplicationMain { }, }; private deviceConfig?: IDeviceConfig; + private hasReceivedDeviceConfig = false; private guiSettings = new GuiSettings(); private tunnelStateExpectation?: Expectation; @@ -647,6 +648,9 @@ class ApplicationMain { // fetch device try { this.setDeviceConfig({ deviceConfig: await this.daemonRpc.getDevice() }); + void this.daemonRpc + .updateDevice() + .catch((error: Error) => log.warn(`Failed to update device info: ${error.message}`)); } catch (e) { const error = e as Error; log.error(`Failed to fetch device: ${error.message}`); @@ -1118,6 +1122,7 @@ class ApplicationMain { private setDeviceConfig(deviceEvent: IDeviceEvent) { const oldDeviceConfig = this.deviceConfig; this.deviceConfig = deviceEvent.deviceConfig; + this.hasReceivedDeviceConfig = true; // make sure to invalidate the account data cache when account tokens change this.updateAccountDataOnAccountChange( @@ -1214,6 +1219,7 @@ class ApplicationMain { tunnelState: this.tunnelState, settings: this.settings, deviceConfig: this.deviceConfig, + hasReceivedDeviceConfig: this.hasReceivedDeviceConfig, relayListPair: { relays: this.processRelaysForPresentation(this.relays, this.settings.relaySettings), bridges: this.processBridgesForPresentation(this.relays, this.settings.bridgeState), diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 4d86e183cc..6e29794a83 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -99,6 +99,7 @@ export default class AppRenderer { private tunnelState!: TunnelState; private settings!: ISettings; private deviceConfig?: IDeviceConfig; + private hasReceivedDeviceConfig = false; private guiSettings!: IGuiSettingsState; private loginState: LoginState = 'none'; private previousLoginState: LoginState = 'none'; @@ -130,6 +131,7 @@ export default class AppRenderer { IpcRendererEventChannel.account.listenDevice((deviceEvent) => { const oldDeviceConfig = this.deviceConfig; + this.hasReceivedDeviceConfig = true; this.handleAccountChange(deviceEvent, oldDeviceConfig?.accountToken); }); @@ -205,6 +207,7 @@ export default class AppRenderer { this.setAccountExpiry(initialState.accountData?.expiry); this.setSettings(initialState.settings); this.handleAccountChange({ deviceConfig: initialState.deviceConfig }, undefined); + this.hasReceivedDeviceConfig = initialState.hasReceivedDeviceConfig; this.setAccountHistory(initialState.accountHistory); this.setTunnelState(initialState.tunnelState); this.updateBlockedState(initialState.tunnelState, initialState.settings.blockWhenDisconnected); @@ -696,7 +699,7 @@ export default class AppRenderer { } private getNavigationBase(): RoutePath { - if (this.connectedToDaemon) { + if (this.connectedToDaemon && this.hasReceivedDeviceConfig) { const loginState = this.reduxStore.getState().account.status; const deviceRevoked = loginState.type === 'none' && loginState.deviceRevoked; diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 79a54a39ba..8f5d0d8d83 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -55,6 +55,7 @@ export interface IAppStateSnapshot { tunnelState: TunnelState; settings: ISettings; deviceConfig?: IDeviceConfig; + hasReceivedDeviceConfig: boolean; relayListPair: IRelayListPair; currentVersion: ICurrentAppVersionInfo; upgradeVersion: IAppVersionInfo; |
