Fix page reloading on initial update (#21410)
Remove the hash event listener before reloading the page, as the reload was being swallowed by our router. Along the way, refactor out routing logic form app.tsx to avoid causing a circular import.
This commit is contained in:
parent
1f97bc2325
commit
adad5e16c2
3 changed files with 94 additions and 58 deletions
|
@ -28,6 +28,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
|
||||
import VectorBasePlatform from './VectorBasePlatform';
|
||||
import { parseQs } from "../url_utils";
|
||||
import { reloadPage } from "../routing";
|
||||
|
||||
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min
|
||||
|
||||
|
@ -128,9 +129,11 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
//
|
||||
// Ideally, loading an old copy would be impossible with the
|
||||
// cache-control: nocache HTTP header set, but Firefox doesn't always obey it :/
|
||||
console.log("startUpdater, current version is " + this.getNormalizedAppVersion(process.env.VERSION));
|
||||
this.pollForUpdate((version: string, newVersion: string) => {
|
||||
const query = parseQs(location);
|
||||
if (query.updated === "1") {
|
||||
console.log("Update reloaded but still on an old version, stopping");
|
||||
// We just reloaded already and are still on the old version!
|
||||
// Show the toast rather than reload in a loop.
|
||||
showUpdateToast(version, newVersion);
|
||||
|
@ -146,8 +149,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
suffix = "&" + suffix;
|
||||
}
|
||||
|
||||
// This line has the effect of loading the page at the new location
|
||||
window.location.href = window.location.href + suffix;
|
||||
reloadPage(window.location.href + suffix);
|
||||
});
|
||||
setInterval(() => this.pollForUpdate(showUpdateToast, hideUpdateToast), POKE_RATE_MS);
|
||||
}
|
||||
|
@ -165,10 +167,14 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
|
||||
if (currentVersion !== mostRecentVersion) {
|
||||
if (this.shouldShowUpdate(mostRecentVersion)) {
|
||||
console.log("Update available to " + mostRecentVersion + ", will notify user");
|
||||
showUpdate(currentVersion, mostRecentVersion);
|
||||
} else {
|
||||
console.log("Update available to " + mostRecentVersion + " but won't be shown");
|
||||
}
|
||||
return { status: UpdateCheckStatus.Ready };
|
||||
} else {
|
||||
console.log("No update available, already on " + mostRecentVersion);
|
||||
showNoUpdate?.();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue