fix: make page navigation not kill css
All checks were successful
deploy to cloudflare pages / deploy (push) Successful in 34s

This commit is contained in:
uku 2024-11-26 12:26:46 +01:00
parent ef25e178bf
commit e986e23767
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o

View file

@ -25,7 +25,12 @@
let solutionLine: L.Polyline | null = $state(null);
onMount(() => {
window.addEventListener("beforeunload", (e) => e.preventDefault());
window.addEventListener("beforeunload", async (e) => {
const gameData = await gamePromise;
if (gameData.stopNames.length > currentIndex + 1) {
e.preventDefault();
}
});
});
async function fetchMap(): Promise<MapData> {
@ -124,7 +129,7 @@
results = null;
if (gameData.stopNames.length <= currentIndex + 1) {
goto("/results?" + new URLSearchParams({ gameId: gameData.gameId }));
window.location.href = "/results?" + new URLSearchParams({ gameId: gameData.gameId });
} else {
currentIndex++;
}