fixes index filterable attributes & auto trail upload

This commit is contained in:
Christian Beutel
2024-06-07 15:06:32 +02:00
parent ad5a4e668b
commit ccb7a4cd3a
11 changed files with 88 additions and 42 deletions

View File

@@ -1,10 +1,28 @@
import { Comment } from "$lib/models/comment";
import type { Trail } from "$lib/models/trail";
import { pb } from "$lib/pocketbase";
import { ClientResponseError } from "pocketbase";
import { writable, type Writable } from "svelte/store";
export const comments: Writable<Comment[]> = writable([])
export async function comments_index(trail: Trail) {
let r = await fetch('/api/v1/comment?' + new URLSearchParams({
filter: `trail = ${trail.id}`,
}), {
method: 'GET',
})
if (!r.ok) {
throw new ClientResponseError(await r.json())
}
const fetchedComments: Comment[] = await r.json();
comments.set(fetchedComments);
return fetchedComments;
}
export async function comments_create(comment: Comment) {
if (!pb.authStore.model) {

View File

@@ -131,7 +131,7 @@ export async function trails_search_bounding_box(northEast: LatLng, southWest: L
export async function trails_show(id: string, loadGPX?: boolean, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
const r = await f(`/api/v1/trail/${id}?` + new URLSearchParams({
expand: "category,waypoints,summit_logs,comments_via_trail.author,trail_share_via_trail",
expand: "category,waypoints,summit_logs,trail_share_via_trail",
}), {
method: 'GET',
})