Skip to content

Commit

Permalink
Normalize the local app version (#20061)
Browse files Browse the repository at this point in the history
We need to strip the leading v from the local app version in pollForUpdate to ensure it compares correctly the version from the /version request indicating what the latest available version is. Previously, we only stripped the leading in getAppVersion which is used in some other places but not to decide whether an update is available.
  • Loading branch information
novocaine committed Dec 6, 2021
1 parent 9b780e0 commit 60788da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/vector/platform/WebPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class WebPlatform extends VectorBasePlatform {
});
}

getAppVersion(): Promise<string> {
getNormalizedAppVersion(): string {
let ver = process.env.VERSION;

// if version looks like semver with leading v, strip it
Expand All @@ -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<string> {
return Promise.resolve(this.getNormalizedAppVersion());
}

startUpdater() {
Expand All @@ -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 {
Expand Down

0 comments on commit 60788da

Please sign in to comment.