From 79d2acec22361dc623d9462181eb520ab1493143 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Fri, 26 Jun 2020 13:02:57 +0200 Subject: [PATCH] drop invalidly dated events entirely --- src/components/StateOptions.jsx | 2 +- src/reducers/validate/validators.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/StateOptions.jsx b/src/components/StateOptions.jsx index a3c2d28..826192e 100644 --- a/src/components/StateOptions.jsx +++ b/src/components/StateOptions.jsx @@ -5,7 +5,7 @@ export default ({ showing, onClickHandler, timelineDims }) => { return null } - const [checked, setChecked] = useState(true) + const [checked, setChecked] = useState(false) const handleCheck = () => setChecked(!checked) const onNarrativise = () => onClickHandler(checked) diff --git a/src/reducers/validate/validators.js b/src/reducers/validate/validators.js index d7db98d..109794c 100644 --- a/src/reducers/validate/validators.js +++ b/src/reducers/validate/validators.js @@ -156,12 +156,14 @@ export function validateDomain (domain) { sanitizedDomain.filters = domain.filters // append events with datetime and sort - sanitizedDomain.events.forEach((event, idx) => { + sanitizedDomain.events = sanitizedDomain.events.filter((event, idx) => { event.id = idx event.datetime = calcDatetime(event.date, event.time) if (!isValidDate(event.datetime)) { - discardedDomain['events'].push({ ...event, error: makeError('events', event.id, `Invalid date. This will break timemap! Please fix.`) }) + discardedDomain['events'].push({ ...event, error: makeError('events', event.id, `Invalid date. It's been dropped, as otherwise timemap won't work as expected.`) }) + return false } + return true }) sanitizedDomain.events.sort((a, b) => a.datetime - b.datetime)