fixes index filterable attributes & auto trail upload
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user