trail save fix

This commit is contained in:
Christian Beutel
2025-02-14 13:22:20 +01:00
parent a2ad4a4800
commit bd8bae2ac9
43 changed files with 164 additions and 105 deletions

View File

@@ -150,7 +150,6 @@ export async function searchLocationReverse(lat: number, lon: number) {
function getLocationDescription(address: Address) {
let description = ""
console.log(address);
if (address.country) {
description += address.country;

View File

@@ -0,0 +1,31 @@
import cryptoRandomString from "crypto-random-string";
export type Toast = {
id?: string;
type: "info" | "success" | "warning" | "error"
icon: string;
text: string;
}
class ToastStore {
toasts: Toast[] = $state([]);
}
export const toastStore = new ToastStore()
export function show_toast(newToast: Toast, duration: number = 3000) {
newToast.id = cryptoRandomString({ length: 15 })
toastStore.toasts.push(newToast);
setTimeout(() => {
closeToast(newToast)
}, duration);
}
export function closeToast(toast: Toast) {
const toastIndex = toastStore.toasts.findIndex(t => t.id == toast.id)
console.log(toastIndex);
toastStore.toasts.splice(toastIndex, 1)
}

View File

@@ -1,17 +0,0 @@
import { writable, type Writable } from "svelte/store";
export type Toast = {
type: "info" | "success" | "warning" | "error"
icon: string;
text: string;
}
export const toast: Writable<Toast | null> = writable();
export function show_toast(newToast: Toast, duration: number = 3000) {
toast.set(newToast);
setTimeout(() => toast.set(null), duration);
}

View File

@@ -304,7 +304,10 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, photos?: F
throw new APIError(r.status, response.message, response.detail)
}
const response: Trail = await r.json();
model.photos = response.photos
model.gpx = response.gpx
trail.set(model);
@@ -460,7 +463,7 @@ async function searchResultToTrailList(hits: Hits<TrailSearchResult>, loadGPX: b
const gpxData: string = await fetchGPX(t);
t.expand!.gpx_data = gpxData;
}
trails.push(t)
}
return trails