Adding the possibility to delete tracks, moving the import button into the track browser, changing the background geolocation precision to 5m and adding a couple of calls to db.compact() and db.viewCleanup().

This commit is contained in:
vdv committed 2022-09-28 09:46:57 +02:00
1 parent 2a0dbef552
commit 2fe7452811
5 files changed
+51 -23

No files matched your search

+24 -16
View File
@@ -132,6 +132,29 @@ export const saveCurrent = async (db: any) => {
}
};
export const deleteGps = async (
db: any,
gps: { _id: string; _rev: string }
) => {
console.log(`Deleting document ${JSON.stringify(gps)}`);
await db.put({ _deleted: true, ...gps });
console.log(`done, id: ${gps}`);
const currentTrkpts = await db.find({
selector: {
type: 'trkpt',
gpx: gps._id,
},
fields: ['_id', '_rev'],
});
console.log(`deleteGps - db.find(trkpts) : ${JSON.stringify(currentTrkpts)}`);
const trkpts: { _id: string; _rev: string }[] = currentTrkpts.docs;
for (let j = 0; j < trkpts.length; j++) {
await db.put({ _deleted: true, ...trkpts[j] });
}
await await db.compact();
await db.viewCleanup();
};
export const deleteCurrent = async (db: any) => {
const currents = await db.find({
selector: {
@@ -144,21 +167,6 @@ export const deleteCurrent = async (db: any) => {
const docs: { _id: string; _rev: string }[] = currents.docs;
for (let i = 0; i < docs.length; i++) {
console.log(`Deleting document ${JSON.stringify(docs[i])}`);
await db.put({ _deleted: true, ...docs[i] });
console.log(`done, id: ${docs[i]._id}`);
const currentTrkpts = await db.find({
selector: {
type: 'trkpt',
gpx: docs[i]._id,
},
fields: ['_id', '_rev', 'type'],
});
console.log(
`deleteCurrent - db.find(trkpts) : ${JSON.stringify(currentTrkpts)}`
);
const trkpts: { _id: string; _rev: string }[] = currentTrkpts.docs;
for (let j = 0; j < trkpts.length; j++) {
await db.put({ _deleted: true, ...trkpts[j] });
}
await deleteGps(db, docs[i]);
}
};
+3
View File
@@ -21,6 +21,9 @@ export const initDb = async (db: any, setDbReady: any) => {
}
}
await await db.compact();
await db.viewCleanup();
// WARNING: defs must use the canonical form and be identical to what will be returned by db.getIndexes
const requiredIndexes: any = [
{