summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-06-15 11:48:40 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-06-28 09:00:49 +0200
commitde10b8a65b37e846bed01956e3a5ac87629d5c16 (patch)
tree91e2302a1d59617a1dd31169474bd1087f77606c /gui/src/renderer
parentbb7fe6f9054d5fb3735fd6836c137885620076d6 (diff)
downloadmullvadvpn-de10b8a65b37e846bed01956e3a5ac87629d5c16.tar.xz
mullvadvpn-de10b8a65b37e846bed01956e3a5ac87629d5c16.zip
Save previous expiry date when expiry changes
Diffstat (limited to 'gui/src/renderer')
-rw-r--r--gui/src/renderer/app.tsx11
-rw-r--r--gui/src/renderer/redux/account/actions.ts4
-rw-r--r--gui/src/renderer/redux/account/reducers.ts5
3 files changed, 15 insertions, 5 deletions
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,
};
}