From 2c4ef208c94c142a17b3ed58d9a45e638a1a5757 Mon Sep 17 00:00:00 2001 From: Type-Style Date: Fri, 19 Jul 2024 14:28:43 +0200 Subject: [PATCH] [Fix] #94, refactor-ignore logic (multiline) Serverside: When writing entry, the most recent previous entry is checked wether to be ignored. Also if more than 2 items already exist meaning writing is preparing at least the 3rd entry, we recalculate distances and timing if previousItems are ignored. Frontend: In order to benefit and get the recent information that a previous item is being ignored, frontEnd askes for the current item again and merges it and following items. Remember the most recent item can never be ignored due to policy. Maybe there is no further writing, so I want to have the latest datapoint. --- src/client/components/Map.tsx | 15 ++++++++++----- src/client/components/Status.tsx | 2 +- src/client/pages/Start.tsx | 24 +++++++++++++++++++----- src/models/entry.ts | 29 +++++++++++++++++++++++------ src/scripts/ignore.ts | 4 ++-- src/tests/integration.test.ts | 19 +++++++++++++------ views/index.ejs | 6 +++--- 7 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/client/components/Map.tsx b/src/client/components/Map.tsx index 3eb782a8..abfe5581 100644 --- a/src/client/components/Map.tsx +++ b/src/client/components/Map.tsx @@ -23,7 +23,9 @@ function Map({ entries }: { entries: Models.IEntry[] }) { if (!entries?.length) { return No Data to be displayed } + const lastEntry = entries.at(-1); + const cleanEntries = entries.filter((entry) => !entry.ignore); return ( @@ -32,11 +34,14 @@ function Map({ entries }: { entries: Models.IEntry[] }) { attribution='© OpenStreetMap contributors' url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> - - - {JSON.stringify(lastEntry, null, 2)} - - + {cleanEntries.map((entry) => + + +
{JSON.stringify(entry, null, 2)}
+
+
+ )} +
) } diff --git a/src/client/components/Status.tsx b/src/client/components/Status.tsx index 48a04bcb..5c1991ea 100644 --- a/src/client/components/Status.tsx +++ b/src/client/components/Status.tsx @@ -44,7 +44,7 @@ function Map({ entries }: { entries: Models.IEntry[] }) { return No Data to be displayed } const statusData = getStatusData(entries); - const lastEntry = entries.at(-1); + //const lastEntry = entries.at(-1); return (