speedup loading some pages (reduce data amount of trail lists) (#236)

* speedup loading some pages (reduce data amount of trail lists)

* optimize code

* fix save bio, if no tileset defined
This commit is contained in:
slothful-vassal
2025-04-08 17:50:25 +02:00
committed by GitHub
parent 3973fe7dd9
commit 809615d2f5
5 changed files with 47 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
import { List, type ListFilter } from "$lib/models/list";
import { List, type ListFilter, ExpandType, ExpandTypeToString } from "$lib/models/list";
import type { Trail } from "$lib/models/trail";
import { pb } from "$lib/pocketbase";
import { type ListResult } from "pocketbase";
@@ -11,7 +11,9 @@ let lists: List[] = []
export const list: Writable<List | null> = writable(null)
export const listTrail: Writable<Trail | null> = writable(null);
export async function lists_index(filter?: ListFilter, page: number = 1, perPage: number = 5, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
export async function lists_index(filter?: ListFilter, page: number = 1, perPage: number = 5,
f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch,
e: ExpandType = ExpandType.All) {
const filterText = filter ? buildFilterText(filter) : ""
const r = await f('/api/v1/list?' + new URLSearchParams({
@@ -19,7 +21,7 @@ export async function lists_index(filter?: ListFilter, page: number = 1, perPage
perPage: perPage.toString(),
page: page.toString(),
filter: filterText,
expand: "trails,trails.waypoints,trails.category,list_share_via_list"
expand: ExpandTypeToString(e),
}), {
method: 'GET',
})
@@ -92,9 +94,11 @@ export async function lists_search_filter(filter: ListFilter, page: number = 1,
}
export async function lists_show(id: string, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
export async function lists_show(id: string, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch
, e: ExpandType = ExpandType.All) {
const r = await f(`/api/v1/list/${id}?` + new URLSearchParams({
expand: "trails,trails.waypoints,trails.category,list_share_via_list"
expand: ExpandTypeToString(e)
}), {
method: 'GET',
})