This commit is contained in:
Eric van der Vlist 2023-02-03 11:59:40 +01:00
parent ccbcd12f96
commit 5658cc0556
6 changed files with 52 additions and 36 deletions

View File

@ -79,20 +79,6 @@ const GpxImportSingleFile: Component<Props> = ({ 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<Props> = ({ gpxFile }) => {
<Show when={statsAndGpx().stats.trkMaybeRte}>
<Typography variant='body1'>{t('trkMaybeRte')}</Typography>
</Show>
{/* <Show when={statsAndGpx().stats.nbTrks > 0}>
<FormControl fullWidth>
<FormLabel>{t('importTrk')}</FormLabel>
<RadioGroup>
<FormControlLabel
control={<Radio color='success' />}
{...controlTrkTransformProps('importNonTimedTrksAsRtes')}
/>
<FormControlLabel
control={<Radio color='secondary' />}
{...controlTrkTransformProps('importAllTrksAsRtes')}
/>
<FormControlLabel
control={<Radio color='error' />}
{...controlTrkTransformProps('importTrksAsTrks')}
/>
</RadioGroup>
</FormControl>
</Show> */}
<Show when={state() === 'importing'}>
<LinearProgress />
</Show>

View File

@ -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];

View File

@ -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) => {

View File

@ -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];

View File

@ -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];

View File

@ -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];