Skip to content

Commit

Permalink
Ensure updated=1 is set as the query string before any # (#21605)
Browse files Browse the repository at this point in the history
* Ensure updated=1 is set as the query string before any #

Co-authored-by: Michael Telatynski <[email protected]>
  • Loading branch information
novocaine and t3chguy authored Apr 20, 2022
1 parent f46a6f2 commit ff89eef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
12 changes: 3 additions & 9 deletions src/vector/platform/WebPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 0 additions & 7 deletions src/vector/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit ff89eef

Please sign in to comment.