trail save fix
This commit is contained in:
@@ -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;
|
||||
|
||||
31
web/src/lib/stores/toast_store.svelte.ts
Normal file
31
web/src/lib/stores/toast_store.svelte.ts
Normal 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)
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user