fixes list not loading with link

This commit is contained in:
Christian Beutel
2025-04-21 20:54:17 +02:00
parent 3804a384c3
commit da253a5867
3 changed files with 17 additions and 15 deletions

View File

@@ -279,7 +279,11 @@
maxY = Math.max(maxY, yMax);
}
return new M.LngLatBounds([minX, minY, maxX, maxY]);
if(minX < Infinity && minY < Infinity && maxX > -Infinity && maxY > -Infinity) {
return new M.LngLatBounds([minX, minY, maxX, maxY]);
} else {
return new M.LngLatBounds([0, 0, 0, 0]);
}
}
function flyToBounds() {

View File

@@ -56,9 +56,7 @@
let markers: M.Marker[] = $state([]);
let showMap: boolean = true;
let selectedList: List | null = $state(
page.url.searchParams.get("list") ? data.lists.items[0] : null,
);
let selectedList: List | null = $state(null);
let selectedTrail: Trail | null = $state(null);
let loading: boolean = $state(false);
@@ -71,7 +69,7 @@
let selectedTrailIndex = $derived(
selectedTrail
? (selectedList?.expand?.trails?.indexOf(selectedTrail) ?? null)
? ((selectedList as List | null)?.expand?.trails?.indexOf(selectedTrail) ?? null)
: null,
);
@@ -80,9 +78,9 @@
);
onMount(() => {
if (page.url.searchParams.get("list") && selectedList) {
setCurrentList(selectedList);
if (page.url.searchParams.get("list")) {
setCurrentList(data.lists.items[0]);
// only the requested list has been loaded at this point
// load all lists the next time the user presses the back button
loadAllListsOnNextBack = true;
@@ -260,12 +258,12 @@
><i class="fa fa-sliders"></i></button
>
{#if $currentUser}
<a
aria-label="New list"
class="btn-primary tooltip"
data-title={$_("new-list")}
href="/lists/edit/new"><i class="fa fa-plus"></i></a
>
<a
aria-label="New list"
class="btn-primary tooltip"
data-title={$_("new-list")}
href="/lists/edit/new"><i class="fa fa-plus"></i></a
>
{/if}
</div>
{#if filterExpanded}

View File

@@ -17,7 +17,7 @@ export const load: Load = async ({ params, fetch, url }) => {
let lists: ListResult<List>;
if (url.searchParams.get("list")) {
try {
const list = await lists_show(url.searchParams.get("list") ?? "", fetch, ExpandType.None)
const list = await lists_show(url.searchParams.get("list") ?? "", fetch)
lists = { items: [list], page: 1, perPage: 1, totalItems: 1, totalPages: 1 }
} catch (e) {