diff --git a/web/src/routes/map/+page.svelte b/web/src/routes/map/+page.svelte index 27594a52..28bb4eeb 100644 --- a/web/src/routes/map/+page.svelte +++ b/web/src/routes/map/+page.svelte @@ -25,6 +25,7 @@ } from "$lib/stores/search_store"; import { trails_search_bounding_box } from "$lib/stores/trail_store"; import { getIconForLocation } from "$lib/util/icon_util"; + import type { Snapshot } from "@sveltejs/kit"; import * as M from "maplibre-gl"; import { onMount } from "svelte"; import { _ } from "svelte-i18n"; @@ -53,6 +54,14 @@ totalPages: 1, }; + export const snapshot: Snapshot = { + capture: () => filter, + restore: (value) => { + filter = value; + handleFilterUpdate(); + }, + }; + async function search(q: string) { const r = await searchMulti({ queries: [ @@ -136,7 +145,7 @@ mapWithElevation?.togglePopup(trail.id!, true); } - async function handleFilterUpdate(filter: TrailFilter) { + async function handleFilterUpdate() { if (!map) { return; } diff --git a/web/src/routes/trails/+page.svelte b/web/src/routes/trails/+page.svelte index 56f31c97..363309cd 100644 --- a/web/src/routes/trails/+page.svelte +++ b/web/src/routes/trails/+page.svelte @@ -5,6 +5,7 @@ import TrailList from "$lib/components/trail/trail_list.svelte"; import type { Trail, TrailFilter } from "$lib/models/trail"; import { trails_search_filter } from "$lib/stores/trail_store"; + import type { Snapshot } from "@sveltejs/kit"; import { onMount } from "svelte"; import { _ } from "svelte-i18n"; @@ -21,6 +22,14 @@ }); let trails: Trail[] = $state([]); + export const snapshot: Snapshot = { + capture: () => filter, + restore: (value) => { + filter = value; + handleFilterUpdate() + }, + }; + onMount(() => { if (window.innerWidth < 768) { filterExpanded = false;