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
pull/18053/head
Michael Telatynski 2021-07-19 09:40:08 +01:00
parent ae2e3e8502
commit b23aad28ca
1 changed files with 5 additions and 0 deletions

View File

@ -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 {