diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-03-08 11:37:57 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-03-09 11:00:00 +0100 |
| commit | 69cd229c5a8528f42b26f1587ec8cc6c77243b28 (patch) | |
| tree | d8f4227c1b8970e7e6ba04acd7926c6d9b43fa86 | |
| parent | dd98011e166ceda47c4e7c5858fb173ecc58c2d3 (diff) | |
| download | mullvadvpn-69cd229c5a8528f42b26f1587ec8cc6c77243b28.tar.xz mullvadvpn-69cd229c5a8528f42b26f1587ec8cc6c77243b28.zip | |
Initialize version info during startup
| -rw-r--r-- | gui/src/main/index.ts | 44 | ||||
| -rw-r--r-- | gui/src/shared/ipc-types.ts | 2 |
2 files changed, 23 insertions, 23 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index df41037d2c..fa059e10e0 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -82,6 +82,7 @@ const DAEMON_RPC_PATH = const AUTO_CONNECT_FALLBACK_DELAY = 6000; +const GUI_VERSION = app.getVersion().replace('.0', ''); /// Mirrors the beta check regex in the daemon. Matches only well formed beta versions const IS_BETA = /^(\d{4})\.(\d+)-beta(\d+)$/; @@ -165,10 +166,10 @@ class ApplicationMain { private relays: IRelayList = { countries: [] }; private currentVersion: ICurrentAppVersionInfo = { - daemon: '', - gui: '', + daemon: undefined, + gui: GUI_VERSION, isConsistent: true, - isBeta: false, + isBeta: IS_BETA.test(GUI_VERSION), }; private upgradeVersion: IAppVersionInfo = { @@ -224,7 +225,7 @@ class ApplicationMain { app.enableSandbox(); } - log.info(`Running version ${app.getVersion()}`); + log.info(`Running version ${this.currentVersion.gui}`); if (process.platform === 'win32') { app.setAppUserModelId('net.mullvad.vpn'); @@ -548,14 +549,6 @@ class ApplicationMain { // fetch the latest version info in background consumePromise(this.fetchLatestVersion()); - // notify user about inconsistent version - const notificationProvider = new InconsistentVersionNotificationProvider({ - consistent: this.currentVersion.isConsistent, - }); - if (notificationProvider.mayDisplay()) { - this.notificationController.notify(notificationProvider.getSystemNotification()); - } - // reset the reconnect backoff when connection established. this.reconnectBackoff.reset(); @@ -604,12 +597,6 @@ class ApplicationMain { } else { log.info('Disconnected from the daemon'); } - - // Set GUI version info if it hasn't already been done. Only happens if the app starts without a - // connection to the daemon. - if (this.currentVersion.gui === '') { - this.setDaemonVersion(''); - } }; private connectToDaemon() { @@ -848,16 +835,29 @@ class ApplicationMain { } private setDaemonVersion(daemonVersion: string) { - const guiVersion = app.getVersion().replace('.0', ''); const versionInfo = { + ...this.currentVersion, daemon: daemonVersion, - gui: guiVersion, - isConsistent: daemonVersion === guiVersion, - isBeta: IS_BETA.test(guiVersion), + isConsistent: daemonVersion === this.currentVersion.gui, }; this.currentVersion = versionInfo; + if (!versionInfo.isConsistent) { + log.info('Inconsistent version', { + guiVersion: versionInfo.gui, + daemonVersion: versionInfo.daemon, + }); + } + + // notify user about inconsistent version + const notificationProvider = new InconsistentVersionNotificationProvider({ + consistent: versionInfo.isConsistent, + }); + if (notificationProvider.mayDisplay()) { + this.notificationController.notify(notificationProvider.getSystemNotification()); + } + // notify renderer if (this.windowController) { IpcMainEventChannel.currentVersion.notify(this.windowController.webContents, versionInfo); diff --git a/gui/src/shared/ipc-types.ts b/gui/src/shared/ipc-types.ts index 7781551ed5..691d54b61b 100644 --- a/gui/src/shared/ipc-types.ts +++ b/gui/src/shared/ipc-types.ts @@ -1,6 +1,6 @@ export interface ICurrentAppVersionInfo { gui: string; - daemon: string; + daemon?: string; isConsistent: boolean; isBeta: boolean; } |
