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) {