Ensure updated=1 is set as the query string before any # (#21605)

* Ensure updated=1 is set as the query string before any #

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21912/head
James Salter 2022-04-20 15:12:24 +01:00 committed by GitHub
parent f46a6f2d92
commit ff89eef01a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 16 deletions

View File

@ -28,7 +28,6 @@ import { logger } from "matrix-js-sdk/src/logger";
import VectorBasePlatform from './VectorBasePlatform'; import VectorBasePlatform from './VectorBasePlatform';
import { parseQs } from "../url_utils"; import { parseQs } from "../url_utils";
import { reloadPage } from "../routing";
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min const POKE_RATE_MS = 10 * 60 * 1000; // 10 min
@ -142,14 +141,9 @@ export default class WebPlatform extends VectorBasePlatform {
// Set updated=1 as a query param so we can detect that we've already done this once // Set updated=1 as a query param so we can detect that we've already done this once
// and reload the page. // and reload the page.
let suffix = "updated=1"; const url = new URL(window.location.href);
if (window.location.search.length === 0) { url.searchParams.set("updated", "1");
suffix = "?" + suffix; window.location.href = url.toString();
} else {
suffix = "&" + suffix;
}
reloadPage(window.location.href + suffix);
}); });
setInterval(() => this.pollForUpdate(showUpdateToast, hideUpdateToast), POKE_RATE_MS); setInterval(() => this.pollForUpdate(showUpdateToast, hideUpdateToast), POKE_RATE_MS);
} }

View File

@ -71,13 +71,6 @@ export function onNewScreen(screen: string, replaceLast = false) {
} }
} }
// reload the page to a different url
export function reloadPage(newUrl: string) {
console.log("reloadPage to " + newUrl);
window.removeEventListener('hashchange', onHashChange);
window.location.href = newUrl;
}
export function init() { export function init() {
window.addEventListener('hashchange', onHashChange); window.addEventListener('hashchange', onHashChange);
} }