mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Get version from build VERSION variable (#19857)
* Fetch version from VERSION set during build * When polling for new versions, compare to VERSION set during build * Strip leading v from version, matching package.sh
This commit is contained in:
parent
9746517ef7
commit
194aeac19e
@ -33,8 +33,6 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min
|
||||
|
||||
export default class WebPlatform extends VectorBasePlatform {
|
||||
private runningVersion: string = null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
// Register service worker if available on this platform
|
||||
@ -102,7 +100,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||
return notification;
|
||||
}
|
||||
|
||||
private getVersion(): Promise<string> {
|
||||
private getMostRecentVersion(): Promise<string> {
|
||||
// We add a cachebuster to the request to make sure that we know about
|
||||
// the most recent version on the origin server. That might not
|
||||
// actually be the version we'd get on a reload (particularly in the
|
||||
@ -131,10 +129,15 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||
}
|
||||
|
||||
getAppVersion(): Promise<string> {
|
||||
if (this.runningVersion !== null) {
|
||||
return Promise.resolve(this.runningVersion);
|
||||
let ver = process.env.VERSION;
|
||||
|
||||
// if version looks like semver with leading v, strip it
|
||||
// (matches scripts/package.sh)
|
||||
const semVerRegex = new RegExp("^v[0-9]+.[0-9]+.[0-9]+(-.+)?$");
|
||||
if (semVerRegex.test(process.env.VERSION)) {
|
||||
ver = process.env.VERSION.substr(1);
|
||||
}
|
||||
return this.getVersion();
|
||||
return Promise.resolve(ver);
|
||||
}
|
||||
|
||||
startUpdater() {
|
||||
@ -147,12 +150,10 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||
}
|
||||
|
||||
pollForUpdate = () => {
|
||||
return this.getVersion().then((ver) => {
|
||||
if (this.runningVersion === null) {
|
||||
this.runningVersion = ver;
|
||||
} else if (this.runningVersion !== ver) {
|
||||
if (this.shouldShowUpdate(ver)) {
|
||||
showUpdateToast(this.runningVersion, ver);
|
||||
return this.getMostRecentVersion().then((mostRecentVersion) => {
|
||||
if (process.env.VERSION !== mostRecentVersion) {
|
||||
if (this.shouldShowUpdate(mostRecentVersion)) {
|
||||
showUpdateToast(process.env.VERSION, mostRecentVersion);
|
||||
}
|
||||
return { status: UpdateCheckStatus.Ready };
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user