From b23aad28ca05ccbcd78f9f13ef466b6918f0e35b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 19 Jul 2021 09:40:08 +0100 Subject: [PATCH 1/2] Fix browser history getting stuck looping back to the same room E.g if you click a link to room/#foo:bar?via=baz we'll redirect to room/#foo:bar and now hitting back takes you back to the ?via=baz and means you have to hit back twice without this change --- src/vector/app.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vector/app.tsx b/src/vector/app.tsx index 50030516805..c405ed8a0d7 100644 --- a/src/vector/app.tsx +++ b/src/vector/app.tsx @@ -73,6 +73,11 @@ function onNewScreen(screen: string, replaceLast = false) { const hash = '#/' + screen; lastLocationHashSet = hash; + // if the new hash is a substring of the old one then we are stripping fields e.g `via` so replace history + if (screen.startsWith("room/") && window.location.hash.startsWith(hash)) { + replaceLast = true; + } + if (replaceLast) { window.location.replace(hash); } else { From 331678b9132ce01eb14c9785e53ffec5d0244f73 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 19 Jul 2021 09:48:50 +0100 Subject: [PATCH 2/2] fix edge case around event permalinks --- src/vector/app.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vector/app.tsx b/src/vector/app.tsx index c405ed8a0d7..d609a2558d8 100644 --- a/src/vector/app.tsx +++ b/src/vector/app.tsx @@ -74,7 +74,10 @@ function onNewScreen(screen: string, replaceLast = false) { lastLocationHashSet = hash; // if the new hash is a substring of the old one then we are stripping fields e.g `via` so replace history - if (screen.startsWith("room/") && window.location.hash.startsWith(hash)) { + if (screen.startsWith("room/") && + window.location.hash.includes("/$") === hash.includes("/$") && // only if both did or didn't contain event link + window.location.hash.startsWith(hash) + ) { replaceLast = true; }