mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
Make selectors compute narratives as arrays
This commit is contained in:
committed by
Lachlan Kermode
parent
0bc4ddc54e
commit
4423e792ec
@@ -26,7 +26,6 @@ class NarrativeCard extends React.Component {
|
||||
componentDidUpdate() {
|
||||
if (this.props.narrative !== null) {
|
||||
const step = this.props.narrative.steps[this.state.step];
|
||||
console.log(step)
|
||||
this.props.onSelect([step]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const eventSchema = Joi.object().keys({
|
||||
longitude: Joi.string().allow('').required(),
|
||||
type: Joi.string().allow(''),
|
||||
category: Joi.string().required(),
|
||||
narrative: Joi.string().allow(''),
|
||||
narratives: Joi.array(),
|
||||
sources: Joi.array(),
|
||||
tags: Joi.string().allow(''),
|
||||
comments: Joi.string().allow(''),
|
||||
|
||||
@@ -95,16 +95,18 @@ export const selectNarratives = createSelector(
|
||||
events.forEach((evt) => {
|
||||
const isTagged = isTaggedIn(evt, tagFilters) || isNoTags(tagFilters);
|
||||
const isTimeRanged = isTimeRangedIn(evt, timeRange);
|
||||
const isInNarrative = evt.narrative;
|
||||
const isInNarrative = evt.narratives.length > 0;
|
||||
|
||||
if (!narratives[evt.narrative]) {
|
||||
narratives[evt.narrative] = { id: evt.narrative, steps: [], byId: {} };
|
||||
}
|
||||
evt.narratives.map(narrative => {
|
||||
if (!narratives[narrative]) {
|
||||
narratives[narrative] = { id: narrative, steps: [], byId: {} };
|
||||
}
|
||||
|
||||
if (/*isTimeRanged && isTagged && */isInNarrative) {
|
||||
narratives[evt.narrative].steps.push(evt);
|
||||
narratives[evt.narrative].byId[evt.id] = { next: null, prev: null };
|
||||
}
|
||||
if (isInNarrative) {
|
||||
narratives[narrative].steps.push(evt);
|
||||
narratives[narrative].byId[evt.id] = { next: null, prev: null };
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Object.keys(narratives).forEach((key) => {
|
||||
@@ -161,6 +163,7 @@ export const selectLocations = createSelector(
|
||||
export const selectSelected = createSelector(
|
||||
[getSelected, getSources],
|
||||
(selected, sources) => {
|
||||
console.log(selected, sources)
|
||||
if (selected.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user