diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-06-15 11:48:40 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-06-28 09:00:49 +0200 |
| commit | de10b8a65b37e846bed01956e3a5ac87629d5c16 (patch) | |
| tree | 91e2302a1d59617a1dd31169474bd1087f77606c /gui/src | |
| parent | bb7fe6f9054d5fb3735fd6836c137885620076d6 (diff) | |
| download | mullvadvpn-de10b8a65b37e846bed01956e3a5ac87629d5c16.tar.xz mullvadvpn-de10b8a65b37e846bed01956e3a5ac87629d5c16.zip | |
Save previous expiry date when expiry changes
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/index.ts | 10 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 11 | ||||
| -rw-r--r-- | gui/src/renderer/redux/account/actions.ts | 4 | ||||
| -rw-r--r-- | gui/src/renderer/redux/account/reducers.ts | 5 | ||||
| -rw-r--r-- | gui/src/shared/daemon-rpc-types.ts | 1 |
5 files changed, 24 insertions, 7 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index cbf798f6f2..1785794818 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -196,10 +196,16 @@ class ApplicationMain { return this.daemonRpc.getAccountData(accountToken); }, (accountData) => { - this.accountData = accountData; + this.accountData = accountData && { + ...accountData, + previousExpiry: + accountData.expiry !== this.accountData?.expiry + ? this.accountData?.expiry + : this.accountData?.previousExpiry, + }; if (this.windowController) { - IpcMainEventChannel.account.notify(this.windowController.webContents, accountData); + IpcMainEventChannel.account.notify(this.windowController.webContents, this.accountData); } this.handleAccountExpiry(); diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 0fdcb47877..9e1555e4ec 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -145,7 +145,7 @@ export default class AppRenderer { }); IpcRendererEventChannel.account.listen((newAccountData?: IAccountData) => { - this.setAccountExpiry(newAccountData && newAccountData.expiry); + this.setAccountExpiry(newAccountData?.expiry, newAccountData?.previousExpiry); }); IpcRendererEventChannel.accountHistory.listen((newAccountHistory?: AccountToken) => { @@ -219,7 +219,10 @@ export default class AppRenderer { initialState.translations.relayLocations, ); - this.setAccountExpiry(initialState.accountData && initialState.accountData.expiry); + this.setAccountExpiry( + initialState.accountData?.expiry, + initialState.accountData?.previousExpiry, + ); this.handleAccountChange(undefined, initialState.settings.accountToken); this.setAccountHistory(initialState.accountHistory); this.setSettings(initialState.settings); @@ -829,8 +832,8 @@ export default class AppRenderer { this.reduxActions.settings.updateGuiSettings(guiSettings); } - private setAccountExpiry(expiry?: string) { - this.reduxActions.account.updateAccountExpiry(expiry); + private setAccountExpiry(expiry?: string, previousExpiry?: string) { + this.reduxActions.account.updateAccountExpiry(expiry, previousExpiry); } private storeAutoStart(autoStart: boolean) { diff --git a/gui/src/renderer/redux/account/actions.ts b/gui/src/renderer/redux/account/actions.ts index b8fbe94d39..4a9790df00 100644 --- a/gui/src/renderer/redux/account/actions.ts +++ b/gui/src/renderer/redux/account/actions.ts @@ -50,6 +50,7 @@ interface IUpdateAccountHistoryAction { interface IUpdateAccountExpiryAction { type: 'UPDATE_ACCOUNT_EXPIRY'; expiry?: string; + previousExpiry?: string; } export type AccountAction = @@ -132,10 +133,11 @@ function updateAccountHistory(accountHistory?: AccountToken): IUpdateAccountHist }; } -function updateAccountExpiry(expiry?: string): IUpdateAccountExpiryAction { +function updateAccountExpiry(expiry?: string, previousExpiry?: string): IUpdateAccountExpiryAction { return { type: 'UPDATE_ACCOUNT_EXPIRY', expiry, + previousExpiry, }; } diff --git a/gui/src/renderer/redux/account/reducers.ts b/gui/src/renderer/redux/account/reducers.ts index 53bc55db1b..6b68fef9cf 100644 --- a/gui/src/renderer/redux/account/reducers.ts +++ b/gui/src/renderer/redux/account/reducers.ts @@ -10,6 +10,7 @@ export interface IAccountReduxState { accountToken?: AccountToken; accountHistory?: AccountToken; expiry?: string; // ISO8601 + previousExpiry?: string; // ISO8601 status: LoginState; } @@ -17,6 +18,7 @@ const initialState: IAccountReduxState = { accountToken: undefined, accountHistory: undefined, expiry: undefined, + previousExpiry: undefined, status: { type: 'none' }, }; @@ -48,6 +50,7 @@ export default function ( status: { type: 'none' }, accountToken: undefined, expiry: undefined, + previousExpiry: undefined, }; case 'RESET_LOGIN_ERROR': return { @@ -70,6 +73,7 @@ export default function ( status: { type: 'ok', method: 'new_account' }, accountToken: action.token, expiry: action.expiry, + previousExpiry: undefined, }; case 'UPDATE_ACCOUNT_TOKEN': return { @@ -85,6 +89,7 @@ export default function ( return { ...state, expiry: action.expiry, + previousExpiry: action.previousExpiry, }; } diff --git a/gui/src/shared/daemon-rpc-types.ts b/gui/src/shared/daemon-rpc-types.ts index 92d08e8d5c..b0319369cf 100644 --- a/gui/src/shared/daemon-rpc-types.ts +++ b/gui/src/shared/daemon-rpc-types.ts @@ -1,5 +1,6 @@ export interface IAccountData { expiry: string; + previousExpiry?: string; } export type AccountToken = string; export type Ip = string; |
