fixes auto upload
This commit is contained in:
@@ -39,10 +39,10 @@ export async function summit_logs_index(filter?: SummitLogFilter, f: (url: Reque
|
||||
return fetchedSummitLogs;
|
||||
}
|
||||
|
||||
export async function summit_logs_create(summitLog: SummitLog) {
|
||||
export async function summit_logs_create(summitLog: SummitLog, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
summitLog.author = pb.authStore.model!.id
|
||||
|
||||
let r = await fetch('/api/v1/summit-log', {
|
||||
let r = await f('/api/v1/summit-log', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(summitLog),
|
||||
})
|
||||
@@ -58,7 +58,7 @@ export async function summit_logs_create(summitLog: SummitLog) {
|
||||
|
||||
formData.append("gpx", summitLog._gpx)
|
||||
|
||||
r = await fetch(`/api/v1/summit-log/${model.id!}/file`, {
|
||||
r = await f(`/api/v1/summit-log/${model.id!}/file`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
@@ -186,7 +186,7 @@ export async function trails_create(trail: Trail, photos: File[], gpx: File | Bl
|
||||
trail.waypoints.push(model.id!);
|
||||
}
|
||||
for (const summitLog of trail.expand.summit_logs) {
|
||||
const model = await summit_logs_create(summitLog);
|
||||
const model = await summit_logs_create(summitLog, f);
|
||||
trail.summit_logs.push(model.id!);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ export async function trails_upload(file: File, f: (url: RequestInfo | URL, conf
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchGPX(trail: { gpx: string } & Record<string, any>, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
export async function fetchGPX(trail: { gpx?: string } & Record<string, any>, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||
if (!trail.gpx) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user