diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-02-23 14:26:10 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:58:44 +0100 |
| commit | 8659f97d48369e3d61aee615bea06ffe30164f83 (patch) | |
| tree | 174564b1865f8c04ee4d637902b5f9cd41a41cc7 /gui/src | |
| parent | 7d37bfd840abfdbbf4ae0f191a3c2afe40f700c9 (diff) | |
| download | mullvadvpn-8659f97d48369e3d61aee615bea06ffe30164f83.tar.xz mullvadvpn-8659f97d48369e3d61aee615bea06ffe30164f83.zip | |
Fix DeviceConfig type to not include undefined
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 6 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 4 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/redux/account/actions.ts | 6 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 12 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 4 |
6 files changed, 17 insertions, 19 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 055fadc4ef..2497bceaeb 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -46,7 +46,7 @@ import { VoucherResponse, TunnelProtocol, IDnsOptions, - DeviceConfig, + IDeviceConfig, IDevice, IDeviceRemoval, IDeviceEvent, @@ -499,7 +499,7 @@ export class DaemonRpc { await this.callEmpty(this.client.checkVolumes); } - public async getDevice(): Promise<DeviceConfig> { + public async getDevice(): Promise<IDeviceConfig | undefined> { try { const response = await this.callEmpty<grpcTypes.DeviceConfig>(this.client.getDevice); return convertFromDeviceConfig(response); @@ -1378,7 +1378,7 @@ function convertFromDeviceEvent(deviceEvent: grpcTypes.DeviceEvent): IDeviceEven }; } -function convertFromDeviceConfig(deviceConfig?: grpcTypes.DeviceConfig): DeviceConfig { +function convertFromDeviceConfig(deviceConfig?: grpcTypes.DeviceConfig): IDeviceConfig | undefined { const device = deviceConfig?.getDevice(); return ( deviceConfig && { diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index da8f3afffb..c53456cc65 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -27,7 +27,7 @@ import { DaemonEvent, IAccountData, IAppVersionInfo, - DeviceConfig, + IDeviceConfig, IDeviceRemoval, IDnsOptions, IRelayList, @@ -197,7 +197,7 @@ class ApplicationMain { }, }, }; - private deviceConfig: DeviceConfig = undefined; + private deviceConfig?: IDeviceConfig; private guiSettings = new GuiSettings(); private tunnelStateExpectation?: Expectation; diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 8558b98050..ea6c12cc84 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -32,7 +32,7 @@ import { IAccountData, IAppVersionInfo, IDevice, - DeviceConfig, + IDeviceConfig, IDeviceRemoval, IDnsOptions, ILocation, @@ -96,7 +96,7 @@ export default class AppRenderer { private relayListPair!: IRelayListPair; private tunnelState!: TunnelState; private settings!: ISettings; - private deviceConfig: DeviceConfig; + private deviceConfig?: IDeviceConfig; private guiSettings!: IGuiSettingsState; private loginState: 'none' | 'logging in' | 'creating account' | 'too many devices' = 'none'; private loginScheduler = new Scheduler(); diff --git a/gui/src/renderer/redux/account/actions.ts b/gui/src/renderer/redux/account/actions.ts index 355acc4a35..aa0a949533 100644 --- a/gui/src/renderer/redux/account/actions.ts +++ b/gui/src/renderer/redux/account/actions.ts @@ -1,4 +1,4 @@ -import { AccountToken, DeviceConfig, IDevice } from '../../../shared/daemon-rpc-types'; +import { AccountToken, IDeviceConfig, IDevice } from '../../../shared/daemon-rpc-types'; interface IStartLoginAction { type: 'START_LOGIN'; @@ -107,7 +107,7 @@ function startLogin(accountToken: AccountToken): IStartLoginAction { }; } -function loggedIn(deviceConfig: NonNullable<DeviceConfig>): ILoggedInAction { +function loggedIn(deviceConfig: IDeviceConfig): ILoggedInAction { return { type: 'LOGGED_IN', accountToken: deviceConfig.accountToken, @@ -172,7 +172,7 @@ function createAccountFailed(error: Error): ICreateAccountFailed { }; } -function accountCreated(deviceConfig: NonNullable<DeviceConfig>, expiry: string): IAccountCreated { +function accountCreated(deviceConfig: IDeviceConfig, expiry: string): IAccountCreated { return { type: 'ACCOUNT_CREATED', accountToken: deviceConfig.accountToken, diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 9f4e02baa0..b08f375e96 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -323,16 +323,14 @@ export interface IAppVersionInfo { } export interface IDeviceEvent { - deviceConfig: DeviceConfig; + deviceConfig?: IDeviceConfig; remote?: boolean; } -export type DeviceConfig = - | undefined - | { - accountToken: AccountToken; - device?: IDevice; - }; +export interface IDeviceConfig { + accountToken: AccountToken; + device?: IDevice; +} export interface IDevice { id: string; diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 89dd0b37b6..29d00bb1c4 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -7,7 +7,7 @@ import { IAccountData, IAppVersionInfo, IDevice, - DeviceConfig, + IDeviceConfig, IDeviceRemoval, IDnsOptions, ILocation, @@ -54,7 +54,7 @@ export interface IAppStateSnapshot { accountHistory?: AccountToken; tunnelState: TunnelState; settings: ISettings; - deviceConfig: DeviceConfig; + deviceConfig?: IDeviceConfig; relayListPair: IRelayListPair; currentVersion: ICurrentAppVersionInfo; upgradeVersion: IAppVersionInfo; |
