From 39901b8d72f0fba6fa83eb522556528c3ad003cd Mon Sep 17 00:00:00 2001 From: James Salter Date: Tue, 7 Dec 2021 02:09:23 +1100 Subject: [PATCH] Normalize the local app version (#20062) We need to strip the leading v from the local app version as well as the one fetched from the server --- src/vector/platform/WebPlatform.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index b7b59826b..f3f3d55ac 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -128,7 +128,7 @@ export default class WebPlatform extends VectorBasePlatform { }); } - getAppVersion(): Promise { + getNormalizedAppVersion(): string { let ver = process.env.VERSION; // if version looks like semver with leading v, strip it @@ -137,7 +137,11 @@ export default class WebPlatform extends VectorBasePlatform { if (semVerRegex.test(process.env.VERSION)) { ver = process.env.VERSION.substr(1); } - return Promise.resolve(ver); + return ver; + } + + getAppVersion(): Promise { + return Promise.resolve(this.getNormalizedAppVersion()); } startUpdater() { @@ -151,9 +155,11 @@ export default class WebPlatform extends VectorBasePlatform { pollForUpdate = () => { return this.getMostRecentVersion().then((mostRecentVersion) => { - if (process.env.VERSION !== mostRecentVersion) { + const currentVersion = this.getNormalizedAppVersion(); + + if (currentVersion !== mostRecentVersion) { if (this.shouldShowUpdate(mostRecentVersion)) { - showUpdateToast(process.env.VERSION, mostRecentVersion); + showUpdateToast(currentVersion, mostRecentVersion); } return { status: UpdateCheckStatus.Ready }; } else {