Workaround for a pouchdb/chrome bug.

This commit is contained in:
Eric van der Vlist 2023-02-02 22:19:31 +01:00
parent 0af58ccb4f
commit ccbcd12f96
5 changed files with 21 additions and 5 deletions

View File

@ -371,9 +371,12 @@ export const getGpx = async (params: any) => {
const docs = await getFamily(id, { include_docs: true }); const docs = await getFamily(id, { include_docs: true });
let target: any[]; let target: any[];
let gpx: Gpx | undefined = undefined; let gpx: Gpx | undefined = undefined;
docs.rows.forEach((row: any) => { docs.rows.every((row: any) => {
// level 0 // level 0
if (row.doc.type === 'gpx') { if (row.doc.type === 'gpx') {
if (!!gpx) {
return false; // Hack to stop if getFamily fails
}
target = [row.doc.doc]; target = [row.doc.doc];
gpx = row.doc.doc; gpx = row.doc.doc;
} }
@ -394,6 +397,7 @@ export const getGpx = async (params: any) => {
appendToArray(target.at(-1), row.doc.type, row.doc._id); appendToArray(target.at(-1), row.doc.type, row.doc._id);
target.push(row.doc.doc); target.push(row.doc.doc);
} }
return true;
}); });
return gpx; return gpx;
}; };

View File

@ -46,7 +46,7 @@ export const getFamily = async (
const targetDb = local ? localDb : db; const targetDb = local ? localDb : db;
return await targetDb.allDocs({ return await targetDb.allDocs({
startkey: key, startkey: key,
endkey: key + '\ufff0', endkey: `${key}\ufff0`,
...options, ...options,
}); });
}; };

View File

@ -37,9 +37,12 @@ export const getRte = async (params: any) => {
const docs = await getFamily(id, { include_docs: true }); const docs = await getFamily(id, { include_docs: true });
let target: any[]; let target: any[];
let rte: Rte | undefined = undefined; let rte: Rte | undefined = undefined;
docs.rows.forEach((row: any) => { docs.rows.every((row: any) => {
// level 0 // level 0
if (row.doc.type === 'rte') { if (row.doc.type === 'rte') {
if (!!rte) {
return false; // Hack to stop if getFamily fails
}
target = [row.doc.doc]; target = [row.doc.doc];
rte = row.doc.doc; rte = row.doc.doc;
} }
@ -50,6 +53,7 @@ export const getRte = async (params: any) => {
appendToArray(target.at(-1), row.doc.type, row.doc.doc); appendToArray(target.at(-1), row.doc.type, row.doc.doc);
target.push(row.doc.doc); target.push(row.doc.doc);
} }
return true;
}); });
return rte; return rte;
}; };

View File

@ -37,9 +37,12 @@ export const getTrk = async (params: any) => {
const docs = await getFamily(id, { include_docs: true }); const docs = await getFamily(id, { include_docs: true });
let target: any[]; let target: any[];
let trk: Trk | undefined = undefined; let trk: Trk | undefined = undefined;
docs.rows.forEach((row: any) => { docs.rows.every((row: any) => {
// level 0 // level 0
if (row.doc.type === 'trk') { if (row.doc.type === 'trk') {
if (!!trk) {
return false; // Hack to stop if getFamily fails
}
target = [row.doc.doc]; target = [row.doc.doc];
trk = row.doc.doc; trk = row.doc.doc;
} }
@ -49,6 +52,7 @@ export const getTrk = async (params: any) => {
appendToArray(target.at(-1), row.doc.type, row.doc._id); appendToArray(target.at(-1), row.doc.type, row.doc._id);
target.push(row.doc.doc); target.push(row.doc.doc);
} }
return true;
}); });
return trk; return trk;
}; };

View File

@ -32,9 +32,12 @@ export const getTrkseg = async (params: any) => {
const docs = await getFamily(id, { include_docs: true }); const docs = await getFamily(id, { include_docs: true });
let target: any[]; let target: any[];
let trkseg: Trkseg | undefined = undefined; let trkseg: Trkseg | undefined = undefined;
docs.rows.forEach((row: any) => { docs.rows.every((row: any) => {
// level 0 // level 0
if (row.doc.type === 'trkseg') { if (row.doc.type === 'trkseg') {
if (!!trkseg) {
return false; // Hack to stop if getFamily fails
}
target = [row.doc.doc]; target = [row.doc.doc];
trkseg = row.doc.doc; trkseg = row.doc.doc;
} }
@ -45,6 +48,7 @@ export const getTrkseg = async (params: any) => {
appendToArray(target.at(-1), row.doc.type, row.doc.doc); appendToArray(target.at(-1), row.doc.type, row.doc.doc);
target.push(row.doc.doc); target.push(row.doc.doc);
} }
return true;
}); });
return trkseg; return trkseg;
}; };