This commit is contained in:
Eric van der Vlist 2023-02-13 15:59:41 +01:00
parent 6dfe98b655
commit 8d32fa253a
2 changed files with 66 additions and 44 deletions

View File

@ -26,11 +26,15 @@ const methods = {
const sendUpdate = async (params: any) => {
if (params) {
console.log({ caller: 'ChangeHandler / sendUpdate', params });
try {
const { method, _dispatchId, id, ...otherParams } = params;
const returnValue = await methods[<keyof typeof methods>method](params);
if (returnValue) {
returnAgain(_dispatchId, returnValue);
}
} catch (error) {
console.error({ caller: 'ChangeHandler / sendUpdate', params, error });
}
}
};

View File

@ -420,14 +420,20 @@ export const appendTrk = async (params: any) => {
export const putGpx = async (params: any) => {
let { id, gpx } = params;
try {
if (id === 'new') {
const date = !!gpx.metadata.time ? new Date(gpx.metadata.time) : new Date();
const date = !!gpx.metadata.time
? new Date(gpx.metadata.time)
: new Date();
id = getUri('gpx', {
gpx: intToGpxId(date.valueOf()),
});
}
const previousShared = (await get(`${id}/4extensions`)).doc?.shared;
let previousShared;
try {
previousShared = (await get(`${id}/4extensions`)).doc?.shared;
} catch (error) {}
console.log({ caller: 'putGpx', params, id, gpx, previousShared });
const extensions = gpx?.extensions;
@ -447,7 +453,10 @@ export const putGpx = async (params: any) => {
extensions
);
} catch (error) {
console.error({ caller: 'putGpx / extensions', error });
console.error({
caller: 'putGpx / extensions',
error,
});
}
}
@ -468,6 +477,15 @@ export const putGpx = async (params: any) => {
});
await db.bulkDocs(family);
}
} catch (error) {
console.error({
caller: 'putGpx',
params,
id,
gpx,
error,
});
}
return id;
};