diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-05-12 14:21:15 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-05-13 10:49:25 +0200 |
| commit | 5c99fdee273b54a26224c79ef839fc3d9f615707 (patch) | |
| tree | 71d4c36555ed0de0184ec945a39f81f4c315ad2f /gui/src/shared | |
| parent | 64f206b034c9480ba21fe89472724121bac321e0 (diff) | |
| download | mullvadvpn-5c99fdee273b54a26224c79ef839fc3d9f615707.tar.xz mullvadvpn-5c99fdee273b54a26224c79ef839fc3d9f615707.zip | |
Update to new device state rpc calls
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/connect-helper.ts | 14 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 18 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 11 |
3 files changed, 21 insertions, 22 deletions
diff --git a/gui/src/shared/connect-helper.ts b/gui/src/shared/connect-helper.ts index b1421cd8ef..d5c563c7ca 100644 --- a/gui/src/shared/connect-helper.ts +++ b/gui/src/shared/connect-helper.ts @@ -1,28 +1,24 @@ -import { AccountToken, TunnelState } from './daemon-rpc-types'; +import { TunnelState } from './daemon-rpc-types'; export function connectEnabled( connectedToDaemon: boolean, - accountToken: AccountToken | undefined, + loggedIn: boolean, tunnelState: TunnelState['state'], ) { return ( connectedToDaemon && - accountToken !== undefined && - accountToken !== '' && + loggedIn && (tunnelState === 'disconnected' || tunnelState === 'disconnecting' || tunnelState === 'error') ); } export function reconnectEnabled( connectedToDaemon: boolean, - accountToken: AccountToken | undefined, + loggedIn: boolean, tunnelState: TunnelState['state'], ) { return ( - connectedToDaemon && - accountToken !== undefined && - accountToken !== '' && - (tunnelState === 'connected' || tunnelState === 'connecting') + connectedToDaemon && loggedIn && (tunnelState === 'connected' || tunnelState === 'connecting') ); } diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index d1eab9cdce..aad35a01f4 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -114,7 +114,7 @@ export type DaemonEvent = | { settings: ISettings } | { relayList: IRelayList } | { appVersionInfo: IAppVersionInfo } - | { device: IDeviceEvent } + | { device: DeviceEvent } | { deviceRemoval: Array<IDevice> }; export interface ITunnelStateRelayInfo { @@ -333,16 +333,20 @@ export interface IAppVersionInfo { suggestedIsBeta?: boolean; } -export interface IDeviceEvent { - deviceConfig?: IDeviceConfig; - remote?: boolean; -} - -export interface IDeviceConfig { +export interface IAccountAndDevice { accountToken: AccountToken; device?: IDevice; } +export type LoggedInDeviceState = { type: 'logged in'; accountAndDevice: IAccountAndDevice }; +export type LoggedOutDeviceState = { type: 'logged out' | 'revoked' }; + +export type DeviceState = LoggedInDeviceState | LoggedOutDeviceState; + +export type DeviceEvent = + | { type: 'logged in' | 'updated' | 'rotated_key'; deviceState: LoggedInDeviceState } + | { type: 'logged out' | 'revoked'; deviceState: LoggedOutDeviceState }; + export interface IDevice { id: string; name: string; diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index e09d552c25..cbe29ee783 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -5,11 +5,11 @@ import { AccountToken, BridgeSettings, BridgeState, + DeviceEvent, + DeviceState, IAccountData, IAppVersionInfo, IDevice, - IDeviceConfig, - IDeviceEvent, IDeviceRemoval, IDnsOptions, ILocation, @@ -62,8 +62,7 @@ export interface IAppStateSnapshot { tunnelState: TunnelState; settings: ISettings; isPerformingPostUpgrade: boolean; - deviceConfig?: IDeviceConfig; - hasReceivedDeviceConfig: boolean; + deviceState?: DeviceState; relayListPair: IRelayListPair; currentVersion: ICurrentAppVersionInfo; upgradeVersion: IAppVersionInfo; @@ -182,7 +181,7 @@ export const ipcSchema = { }, account: { '': notifyRenderer<IAccountData | undefined>(), - device: notifyRenderer<IDeviceEvent>(), + device: notifyRenderer<DeviceEvent>(), devices: notifyRenderer<Array<IDevice>>(), create: invoke<void, string>(), login: invoke<AccountToken, void>(), @@ -190,7 +189,7 @@ export const ipcSchema = { getWwwAuthToken: invoke<void, string>(), submitVoucher: invoke<string, VoucherResponse>(), updateData: send<void>(), - getDevice: invoke<void, IDevice | undefined>(), + getDeviceState: invoke<void, DeviceState>(), listDevices: invoke<AccountToken, Array<IDevice>>(), removeDevice: invoke<IDeviceRemoval, void>(), }, |
