summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-05-18 14:37:14 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-05-25 12:56:47 +0200
commit00591c5fdeb5d56e21c5bc717201d743a289b9db (patch)
tree2c688e90239016071ab7b423a1307f1b143fa9b8
parentc188675f5d2486a91ed50e355e331f90fb61a233 (diff)
downloadmullvadvpn-00591c5fdeb5d56e21c5bc717201d743a289b9db.tar.xz
mullvadvpn-00591c5fdeb5d56e21c5bc717201d743a289b9db.zip
Use null instead of undefined to represent up to date in nextUpdate
Electron is removing values that are undefined when sending objects through the IPC and therefore doesn't update the redux state when using the spread operator. To solve this, this commit uses null instead of undefined to represent that there are no upgrades.
-rw-r--r--gui/src/main/index.ts15
-rw-r--r--gui/src/renderer/redux/version/actions.ts2
-rw-r--r--gui/src/renderer/redux/version/reducers.ts4
-rw-r--r--gui/test/components/NotificationArea.spec.tsx1
4 files changed, 10 insertions, 12 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 00aa31abdb..2467b511d0 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -68,7 +68,8 @@ export interface ICurrentAppVersionInfo {
}
export interface IAppUpgradeInfo extends IAppVersionInfo {
- nextUpgrade?: string;
+ // Null is used since undefined properties get filtered out when sending through IPC.
+ nextUpgrade: string | null;
}
type AccountVerification = { status: 'verified' } | { status: 'deferred'; error: Error };
@@ -143,7 +144,7 @@ class ApplicationMain {
latestStable: '',
latestBeta: '',
latest: '',
- nextUpgrade: undefined,
+ nextUpgrade: null,
};
// The UI locale which is set once from onReady handler
@@ -752,15 +753,11 @@ class ApplicationMain {
private setLatestVersion(latestVersionInfo: IAppVersionInfo) {
const settings = this.settings;
- function nextUpgrade(
- current: string,
- latest: string,
- latestStable: string,
- ): string | undefined {
+ function nextUpgrade(current: string, latest: string, latestStable: string): string | null {
if (settings.showBetaReleases) {
- return current === latest ? undefined : latest;
+ return current === latest ? null : latest;
} else {
- return current === latestStable ? undefined : latestStable;
+ return current === latestStable ? null : latestStable;
}
}
diff --git a/gui/src/renderer/redux/version/actions.ts b/gui/src/renderer/redux/version/actions.ts
index eb8a81a43d..1826b0a82f 100644
--- a/gui/src/renderer/redux/version/actions.ts
+++ b/gui/src/renderer/redux/version/actions.ts
@@ -1,7 +1,7 @@
import { IAppVersionInfo } from '../../../shared/daemon-rpc-types';
interface IUpdateLatestActionPayload extends IAppVersionInfo {
- nextUpgrade?: string;
+ nextUpgrade: string | null;
}
export interface IUpdateLatestAction {
diff --git a/gui/src/renderer/redux/version/reducers.ts b/gui/src/renderer/redux/version/reducers.ts
index 9932628e02..fdf74c8c0a 100644
--- a/gui/src/renderer/redux/version/reducers.ts
+++ b/gui/src/renderer/redux/version/reducers.ts
@@ -5,7 +5,7 @@ export interface IVersionReduxState {
currentIsSupported: boolean;
latest?: string;
latestStable?: string;
- nextUpgrade?: string;
+ nextUpgrade: string | null;
consistent: boolean;
}
@@ -14,7 +14,7 @@ const initialState: IVersionReduxState = {
currentIsSupported: true,
latest: undefined,
latestStable: undefined,
- nextUpgrade: undefined,
+ nextUpgrade: null,
consistent: true,
};
diff --git a/gui/test/components/NotificationArea.spec.tsx b/gui/test/components/NotificationArea.spec.tsx
index 7be9de56e1..5109b5995d 100644
--- a/gui/test/components/NotificationArea.spec.tsx
+++ b/gui/test/components/NotificationArea.spec.tsx
@@ -13,6 +13,7 @@ describe('components/NotificationArea', () => {
current: '2018.2',
latest: '2018.2-beta1',
latestStable: '2018.2',
+ nextUpgrade: null,
};
const defaultExpiry = new AccountExpiry(moment().add(1, 'year').format(), 'en');