drop invalidly dated events entirely

This commit is contained in:
Lachlan Kermode
2020-06-26 13:02:57 +02:00
parent cdd88917d4
commit 79d2acec22
2 changed files with 5 additions and 3 deletions

View File

@@ -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)

View File

@@ -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)