Adding a "shared" property to gpxes and family.
This commit is contained in:
1 parent
8853ea4670
commit
9dacad9af3
6 files changed
+66
-7
No files matched your search
@@ -43,7 +43,7 @@ for (const property in methods) {
|
||||
}
|
||||
|
||||
const changeHandler = async (change: any) => {
|
||||
// console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
||||
// console.log({ caller: 'ChangeHandler', change, watches: globalThis.watches });
|
||||
const { id } = change;
|
||||
if (!globalThis.watches) {
|
||||
globalThis.watches = new Map();
|
||||
|
||||
+38
-4
@@ -1,3 +1,4 @@
|
||||
import { Rowing } from '@suid/icons-material';
|
||||
import { cloneDeep, isEmpty } from 'lodash';
|
||||
import { PureComponent } from 'react';
|
||||
import { $DEVCOMP } from 'solid-js';
|
||||
@@ -423,9 +424,20 @@ export const getGpx = async (params: any) => {
|
||||
}
|
||||
//level 1 (extensions)
|
||||
if (target !== undefined && row.doc.type === 'extensions') {
|
||||
target.splice(1);
|
||||
appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||
target.push(row.doc.doc);
|
||||
console.log({
|
||||
caller: 'getGpx / extensions',
|
||||
gpx,
|
||||
row,
|
||||
doc: row.doc.doc,
|
||||
gpx_extensions: gpx?.extensions,
|
||||
target,
|
||||
});
|
||||
|
||||
gpx.extensions = row.doc.doc;
|
||||
|
||||
// target.splice(1);
|
||||
// appendToArray(target.at(-1), row.doc.type, row.doc.doc);
|
||||
// target.push(row.doc.doc);
|
||||
}
|
||||
//level 1 (others)
|
||||
if (
|
||||
@@ -477,7 +489,10 @@ export const putGpx = async (params: any) => {
|
||||
gpx: intToGpxId(date.valueOf()),
|
||||
});
|
||||
}
|
||||
console.log({ caller: 'putGpx', params, id, gpx });
|
||||
|
||||
const previousShared = (await get(`${id}/4extensions`)).doc?.shared;
|
||||
|
||||
console.log({ caller: 'putGpx', params, id, gpx, previousShared });
|
||||
const extensions = gpx?.extensions;
|
||||
|
||||
gpx.extensions = undefined;
|
||||
@@ -494,5 +509,24 @@ export const putGpx = async (params: any) => {
|
||||
extensions
|
||||
);
|
||||
}
|
||||
|
||||
if (previousShared !== extensions?.shared) {
|
||||
const shared = extensions?.shared.split(/\s*,\s*/);
|
||||
const family = (await getFamily(id, { include_docs: true })).rows.map(
|
||||
(row: any) => {
|
||||
return { ...row.doc, shared };
|
||||
}
|
||||
);
|
||||
console.log({
|
||||
caller: 'putGpx / updateShared',
|
||||
params,
|
||||
id,
|
||||
gpx,
|
||||
previousShared,
|
||||
family,
|
||||
});
|
||||
await db.bulkDocs(family);
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
Vendored
+2
-1
@@ -49,7 +49,8 @@ interface Extensions {
|
||||
'dyo:batterylevel'?: number;
|
||||
'dyo:useragent'?: string;
|
||||
'dyo:minZoom'?: number;
|
||||
address: any;
|
||||
address?: any;
|
||||
shared?: string;
|
||||
}
|
||||
|
||||
interface Trk {
|
||||
|
||||
Reference in new issue
Block a user