adjust selectors to handle array of sources

This commit is contained in:
Lachlan Kermode
2018-12-13 17:40:30 +00:00
parent 8435df1430
commit c85b0c9001
2 changed files with 6 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ const eventSchema = Joi.object().keys({
type: Joi.string().allow(''),
category: Joi.string().required(),
narrative: Joi.string().allow(''),
source: Joi.string().allow(''),
sources: Joi.array(),
tags: Joi.string().allow(''),
comments: Joi.string().allow(''),
timestamp: Joi.string().required(),

View File

@@ -165,12 +165,14 @@ export const selectSelected = createSelector(
return []
}
const srcs = selected
.map(e => e.source)
.map(id => sources[id])
.map(e => e.sources)
.map(_sources =>
_sources.map(id => sources[id])
)
return selected.map((s, idx) => ({
...s,
source: srcs[idx]
sources: srcs[idx]
}))
}
)