summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2020-06-25 15:22:23 +0100
committerEmīls <emils@mullvad.net>2020-06-25 15:22:23 +0100
commitc586258b52f0d14aedc333d877484da4f3805e05 (patch)
tree9492cde4c155fb83cef7d63627e8647af1194015 /gui/src/main
parent010d7a9771a980491959bbddf97214928c9e4e93 (diff)
parentc147d3b36bcd1a4be37da0aaef9d49f5ce40bcee (diff)
downloadmullvadvpn-c586258b52f0d14aedc333d877484da4f3805e05.tar.xz
mullvadvpn-c586258b52f0d14aedc333d877484da4f3805e05.zip
Merge branch 'version-check-supress-notification'
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/daemon-rpc.ts4
-rw-r--r--gui/src/main/index.ts53
2 files changed, 14 insertions, 43 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 7740dfa26c..656efd760b 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -294,9 +294,7 @@ const tunnelStateSchema = oneOf(
const appVersionInfoSchema = partialObject({
supported: boolean,
- latest: string,
- latest_stable: string,
- latest_beta: string,
+ suggested_upgrade: maybe(string),
});
export class ConnectionObserver {
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 0bdc71a2ef..d6a01e6fd1 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -64,6 +64,9 @@ const DAEMON_RPC_PATH =
const AUTO_CONNECT_FALLBACK_DELAY = 6000;
+/// Mirrors the beta check regex in the daemon. Matches only well formed beta versions
+const IS_BETA = /^(\d{4})\.(\d+)-beta(\d+)$/;
+
enum AppQuitStage {
unready,
initiated,
@@ -77,11 +80,6 @@ export interface ICurrentAppVersionInfo {
isBeta: boolean;
}
-export interface IAppUpgradeInfo extends IAppVersionInfo {
- // Null is used since undefined properties get filtered out when sending through IPC.
- nextUpgrade: string | null;
-}
-
type AccountVerification = { status: 'verified' } | { status: 'deferred'; error: Error };
class ApplicationMain {
@@ -154,12 +152,9 @@ class ApplicationMain {
isBeta: false,
};
- private upgradeVersion: IAppUpgradeInfo = {
+ private upgradeVersion: IAppVersionInfo = {
supported: true,
- latestStable: '',
- latestBeta: '',
- latest: '',
- nextUpgrade: null,
+ suggestedUpgrade: undefined,
};
// The UI locale which is set once from onReady handler
@@ -773,7 +768,7 @@ class ApplicationMain {
daemon: daemonVersion,
gui: guiVersion,
isConsistent: daemonVersion === guiVersion,
- isBeta: guiVersion.includes('beta'),
+ isBeta: IS_BETA.test(guiVersion),
};
this.currentVersion = versionInfo;
@@ -785,45 +780,23 @@ class ApplicationMain {
}
private setLatestVersion(latestVersionInfo: IAppVersionInfo) {
- const settings = this.settings;
-
- function nextUpgrade(current: string, latest: string, latestStable: string): string | null {
- if (settings.showBetaReleases) {
- return current === latest ? null : latest;
- } else {
- return current === latestStable ? null : latestStable;
- }
- }
-
- const currentVersionInfo = this.currentVersion;
- const latestVersion = latestVersionInfo.latest;
- const latestStableVersion = latestVersionInfo.latestStable;
-
- const upgradeVersion = nextUpgrade(
- currentVersionInfo.daemon,
- latestVersion,
- latestStableVersion,
- );
-
- const upgradeInfo = {
- ...latestVersionInfo,
- nextUpgrade: upgradeVersion,
- };
-
- this.upgradeVersion = upgradeInfo;
+ this.upgradeVersion = latestVersionInfo;
// notify user to update the app if it became unsupported
const notificationProvider = new UnsupportedVersionNotificationProvider({
supported: latestVersionInfo.supported,
- consistent: currentVersionInfo.isConsistent,
- nextUpgrade: upgradeVersion,
+ consistent: this.currentVersion.isConsistent,
+ suggestedUpgrade: latestVersionInfo.suggestedUpgrade,
});
if (notificationProvider.mayDisplay()) {
this.notificationController.notify(notificationProvider.getSystemNotification());
}
if (this.windowController) {
- IpcMainEventChannel.upgradeVersion.notify(this.windowController.webContents, upgradeInfo);
+ IpcMainEventChannel.upgradeVersion.notify(
+ this.windowController.webContents,
+ latestVersionInfo,
+ );
}
}