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
This commit is contained in:
Michael Telatynski 2021-07-19 09:40:08 +01:00
parent ae2e3e8502
commit b23aad28ca

View File

@ -73,6 +73,11 @@ function onNewScreen(screen: string, replaceLast = false) {
const hash = '#/' + screen; const hash = '#/' + screen;
lastLocationHashSet = hash; 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) { if (replaceLast) {
window.location.replace(hash); window.location.replace(hash);
} else { } else {