fix: add beforeunload listener to game page

This commit is contained in:
uku 2024-11-25 16:36:34 +01:00
parent 67d2358a37
commit 06c0dc8271
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o

View file

@ -2,6 +2,7 @@
import type { CheckData, CheckResponse, ClientGameData, MapData } from "$lib/types";
import { goto } from "$app/navigation";
import { page } from "$app/stores";
import { onMount } from "svelte";
import L from "leaflet";
import "leaflet/dist/leaflet.css";
@ -23,6 +24,10 @@
let solutionMarker: L.Marker | null = $state(null);
let solutionLine: L.Polyline | null = $state(null);
onMount(() => {
window.addEventListener("beforeunload", (e) => e.preventDefault());
});
async function fetchMap(): Promise<MapData> {
return fetch("/api/map?" + $page.url.searchParams).then((r) => r.json());
}