diff --git a/src/components/gpx-import/GpxImportSingleFile.tsx b/src/components/gpx-import/GpxImportSingleFile.tsx index 96e591c..af9cdf3 100644 --- a/src/components/gpx-import/GpxImportSingleFile.tsx +++ b/src/components/gpx-import/GpxImportSingleFile.tsx @@ -79,20 +79,6 @@ const GpxImportSingleFile: Component = ({ gpxFile }) => { const doImport = async () => { setState('importing'); - // for (const file of event.target.files) { - // const fileReader = new FileReader(); - // fileReader.readAsText(file); - - // fileReader.addEventListener( - // 'load', - // async () => { - // // this will then display a text file - // console.log({ - // caller: 'GpxImport / XML', - // file, - // result: fileReader.result, - // }); - // const gpx = GPX.parse(fileReader.result); // console.log({ caller: 'GpxImport / JSON', file, gpx }); // if (gpx) { // const startTime = new Date(findStartTime(gpx)!); @@ -167,25 +153,6 @@ const GpxImportSingleFile: Component = ({ gpxFile }) => { {t('trkMaybeRte')} - {/* 0}> - - {t('importTrk')} - - } - {...controlTrkTransformProps('importNonTimedTrksAsRtes')} - /> - } - {...controlTrkTransformProps('importAllTrksAsRtes')} - /> - } - {...controlTrkTransformProps('importTrksAsTrks')} - /> - - - */} diff --git a/src/db/gpx.ts b/src/db/gpx.ts index 21f4016..0dadad6 100644 --- a/src/db/gpx.ts +++ b/src/db/gpx.ts @@ -276,7 +276,13 @@ export const pruneAndSaveImportedGpx = async (params: any) => { ]; } else { gpxId = getUri('gpx', id); - previousGpx = (await getGpx(id)) ?? null; + previousGpx = (await getGpx({ id })) ?? null; + console.log({ + caller: 'pruneAndSaveImportedGpx / previousGpx', + id, + previousGpx, + gpxId, + }); } prune(gpxId, gpx, previousGpx, extensions, docs); console.log({ caller: 'pruneAndSaveImportedGpx / pruned', docs }); @@ -375,6 +381,14 @@ export const getGpx = async (params: any) => { // level 0 if (row.doc.type === 'gpx') { if (!!gpx) { + console.error({ + caller: 'getGpx', + id, + row, + target, + gpx, + }); + return false; // Hack to stop if getFamily fails } target = [row.doc.doc]; diff --git a/src/db/lib.ts b/src/db/lib.ts index 23e3736..7df0c60 100644 --- a/src/db/lib.ts +++ b/src/db/lib.ts @@ -44,11 +44,23 @@ export const getFamily = async ( local: boolean = false ) => { const targetDb = local ? localDb : db; - return await targetDb.allDocs({ + const endkey = `${key}\ufff0`; + const allDocs = await targetDb.allDocs({ startkey: key, - endkey: `${key}\ufff0`, + endkey, ...options, }); + if (allDocs.rows.at(-1).id > endkey) { + console.error({ + caller: 'getFamilly', + key, + endkey, + options, + local, + allDocs, + }); + } + return allDocs; }; export const get = async (id: string, local: boolean = false) => { diff --git a/src/db/rte.ts b/src/db/rte.ts index 6420f0f..7d77505 100644 --- a/src/db/rte.ts +++ b/src/db/rte.ts @@ -41,6 +41,13 @@ export const getRte = async (params: any) => { // level 0 if (row.doc.type === 'rte') { if (!!rte) { + console.error({ + caller: 'getRte', + id, + row, + target, + rte, + }); return false; // Hack to stop if getFamily fails } target = [row.doc.doc]; diff --git a/src/db/trk.ts b/src/db/trk.ts index ece71e2..5a0441c 100644 --- a/src/db/trk.ts +++ b/src/db/trk.ts @@ -41,6 +41,14 @@ export const getTrk = async (params: any) => { // level 0 if (row.doc.type === 'trk') { if (!!trk) { + console.error({ + caller: 'getTrk', + id, + row, + target, + trk, + }); + return false; // Hack to stop if getFamily fails } target = [row.doc.doc]; diff --git a/src/db/trkseg.ts b/src/db/trkseg.ts index 3d70485..a788911 100644 --- a/src/db/trkseg.ts +++ b/src/db/trkseg.ts @@ -36,6 +36,14 @@ export const getTrkseg = async (params: any) => { // level 0 if (row.doc.type === 'trkseg') { if (!!trkseg) { + console.error({ + caller: 'getTrkseg', + id, + row, + target, + trkseg, + }); + return false; // Hack to stop if getFamily fails } target = [row.doc.doc];