From b025c74d993fc25ab80a2c459fe568ea579f4e8d Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 5 Aug 2023 17:38:08 +0200 Subject: [PATCH] Displaying only the current GPX if required --- .../drawing-selector/DrawingSelector.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/drawing-selector/DrawingSelector.tsx b/src/components/drawing-selector/DrawingSelector.tsx index 651e071..06fe127 100644 --- a/src/components/drawing-selector/DrawingSelector.tsx +++ b/src/components/drawing-selector/DrawingSelector.tsx @@ -9,6 +9,7 @@ import { getDrawingSelections } from '../../db/drawing-selections'; import dispatch from '../../workers/dispatcher-main'; import { Feature } from 'ol'; import uri from '../../lib/ids'; +import { currentGpxId } from '../gpx-dialog'; const id = getUri('drawingSelections', undefined); @@ -61,20 +62,25 @@ const AllNoneCurrent: Component<{}> = (props) => { ); }; +const gpxSelection = () => drawingSelections().gpxSelection; + export const mustBeDrawn = (feature: Feature) => { - const id = feature.getId(); + const id = feature.getId() as String; const type = feature.get('type'); - const idObj = uri(type, id); - const gpxId = idObj.gpx; console.log({ caller: 'DrawingSelector / mustBeDrawn', feature, type, id, - idObj, - gpxId, + currentGpxId: currentGpxId(), + gpxSelection: gpxSelection(), }); - if (drawingSelections().gpxSelection === 'ALL') return true; + if (gpxSelection() === 'ALL') { + return true; + } + if (gpxSelection() === 'CURRENT') { + return id.startsWith(currentGpxId()); + } return false; };