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); 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() { function flyToBounds() {

View File

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

View File

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