Still working on trk delete.
This commit is contained in:
parent
45f7c797e7
commit
9931887f03
|
@ -1,10 +1,4 @@
|
|||
import {
|
||||
Component,
|
||||
createEffect,
|
||||
For,
|
||||
onCleanup,
|
||||
Suspense,
|
||||
} from 'solid-js';
|
||||
import { Component, createEffect, For, onCleanup, Suspense } from 'solid-js';
|
||||
|
||||
import OlMap from 'ol/Map';
|
||||
|
||||
|
@ -33,6 +27,13 @@ export const Gpx: Component<Props> = ({ map, gpxId }) => {
|
|||
const gpx = createCachedSignal(params);
|
||||
|
||||
onCleanup(() => {
|
||||
console.log({
|
||||
caller: 'Gpx / onCleanup',
|
||||
gpxId,
|
||||
gpx: gpx(),
|
||||
params,
|
||||
});
|
||||
|
||||
destroyCachedSignal(params);
|
||||
});
|
||||
|
||||
|
|
|
@ -22,6 +22,13 @@ export const Rte: Component<Props> = ({ vectorSource, rteId, context }) => {
|
|||
const rte = createCachedSignal(params);
|
||||
|
||||
onCleanup(() => {
|
||||
console.log({
|
||||
caller: 'Rte / onCleanup',
|
||||
rteId,
|
||||
rte: rte(),
|
||||
params,
|
||||
});
|
||||
|
||||
destroyCachedSignal(params);
|
||||
});
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ export const Trk: Component<Props> = ({ vectorSource, trkId, context }) => {
|
|||
const trk = createCachedSignal(params);
|
||||
|
||||
onCleanup(() => {
|
||||
console.log({ caller: 'Trk / onCleanup', trkId, trk: trk(), params });
|
||||
destroyCachedSignal(params);
|
||||
});
|
||||
|
||||
|
|
|
@ -25,8 +25,24 @@ export const Trkseg: Component<Props> = ({
|
|||
};
|
||||
const trkseg = createCachedSignal(params);
|
||||
|
||||
const clearFeatures = () => {
|
||||
[`${trksegId}/start`, trksegId, `${trksegId}/end`].forEach((id) => {
|
||||
const feature = vectorSource.getFeatureById(id);
|
||||
if (feature) {
|
||||
vectorSource.removeFeature(feature);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onCleanup(() => {
|
||||
console.log({
|
||||
caller: 'Trkseg / onCleanup',
|
||||
trksegId,
|
||||
trkseg: trkseg(),
|
||||
params,
|
||||
});
|
||||
destroyCachedSignal(params);
|
||||
clearFeatures();
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
|
@ -86,12 +102,7 @@ export const Trkseg: Component<Props> = ({
|
|||
|
||||
const features = new GeoJSON().readFeatures(geo);
|
||||
console.log({ caller: 'Trkseg', features });
|
||||
[`${trksegId}/start`, trksegId, `${trksegId}/end`].forEach((id) => {
|
||||
const feature = vectorSource.getFeatureById(id);
|
||||
if (feature) {
|
||||
vectorSource.removeFeature(feature);
|
||||
}
|
||||
});
|
||||
clearFeatures();
|
||||
vectorSource.addFeatures(features);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -38,6 +38,13 @@ export const Wpt: Component<Props> = ({
|
|||
const wpt = createCachedSignal(params);
|
||||
|
||||
onCleanup(() => {
|
||||
console.log({
|
||||
caller: 'Wpt / onCleanup',
|
||||
wptId,
|
||||
wpt: wpt(),
|
||||
params,
|
||||
});
|
||||
|
||||
destroyCachedSignal(params);
|
||||
});
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ export const deleteTrk = async (params: any) => {
|
|||
const { id } = params;
|
||||
const docs = await getFamily(id, { include_docs: false });
|
||||
console.log({ caller: 'deleteTrk' }, id, docs);
|
||||
const deletedDocs = docs.rows.map((doc: any) => ({
|
||||
const deletedDocs = docs.rows.reverse().map((doc: any) => ({
|
||||
_deleted: true,
|
||||
_id: doc.id,
|
||||
_rev: doc.value.rev,
|
||||
|
|
Loading…
Reference in New Issue