From ff89eef01a64cb06530b065a752492ec477e3338 Mon Sep 17 00:00:00 2001 From: James Salter Date: Wed, 20 Apr 2022 15:12:24 +0100 Subject: [PATCH] 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> --- src/vector/platform/WebPlatform.ts | 12 +++--------- src/vector/routing.ts | 7 ------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index 6b1d179857..1705c3749f 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -28,7 +28,6 @@ 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 @@ -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 // and reload the page. - let suffix = "updated=1"; - if (window.location.search.length === 0) { - suffix = "?" + suffix; - } else { - suffix = "&" + suffix; - } - - reloadPage(window.location.href + suffix); + const url = new URL(window.location.href); + url.searchParams.set("updated", "1"); + window.location.href = url.toString(); }); setInterval(() => this.pollForUpdate(showUpdateToast, hideUpdateToast), POKE_RATE_MS); } diff --git a/src/vector/routing.ts b/src/vector/routing.ts index 07babd6a77..73d5794179 100644 --- a/src/vector/routing.ts +++ b/src/vector/routing.ts @@ -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() { window.addEventListener('hashchange', onHashChange); }