mirror of
https://github.com/AndrioCelos/TableturfBattleApp.git
synced 2026-08-24 03:44:13 -05:00
Client: Don't run popstate handler on programmatic hash change
This commit is contained in:
@@ -49,15 +49,20 @@ maxPlayersBox.addEventListener('change', () => {
|
||||
});
|
||||
|
||||
function setUrl(path: string) {
|
||||
if (canPushState) {
|
||||
try {
|
||||
history.pushState(null, '', path);
|
||||
} catch {
|
||||
canPushState = false;
|
||||
settingUrl = true;
|
||||
try {
|
||||
if (canPushState) {
|
||||
try {
|
||||
history.pushState(null, '', path);
|
||||
} catch {
|
||||
canPushState = false;
|
||||
location.hash = `#${path}`;
|
||||
}
|
||||
} else
|
||||
location.hash = `#${path}`;
|
||||
}
|
||||
} else
|
||||
location.hash = `#${path}`;
|
||||
} finally {
|
||||
settingUrl = false;
|
||||
}
|
||||
}
|
||||
function setGameUrl(gameID: string) { setUrl(`game/${gameID}`); }
|
||||
|
||||
@@ -177,8 +182,10 @@ function processUrl() {
|
||||
}
|
||||
}
|
||||
|
||||
let settingUrl = false;
|
||||
window.addEventListener('popstate', () => {
|
||||
processUrl();
|
||||
if (!settingUrl)
|
||||
processUrl();
|
||||
});
|
||||
processUrl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user