mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
add null check for sources
This commit is contained in:
@@ -7,7 +7,7 @@ const sourceSchema = Joi.object().keys({
|
||||
affil_1: Joi.string().allow(''),
|
||||
affil_2: Joi.string().allow(''),
|
||||
url: Joi.string().allow(''),
|
||||
title: Joi.string().allow(''),
|
||||
desc: Joi.string().allow(''),
|
||||
parent: Joi.string().allow(''),
|
||||
author: Joi.string().allow(''),
|
||||
date: Joi.string().allow(''),
|
||||
|
||||
@@ -170,8 +170,12 @@ export const selectSelected = createSelector(
|
||||
// NB: return source object if exists, otherwise null
|
||||
const srcs = selected
|
||||
.map(e => e.sources)
|
||||
.map(_sources =>
|
||||
_sources.map(id => (sources.hasOwnProperty(id) ? sources[id] : null))
|
||||
.map(_sources => {
|
||||
if (!_sources) return [];
|
||||
return _sources.map(id => (
|
||||
sources.hasOwnProperty(id) ? sources[id] : null
|
||||
))
|
||||
}
|
||||
)
|
||||
|
||||
return selected.map((s, idx) => ({
|
||||
|
||||
Reference in New Issue
Block a user