From e989e7b6a226003a9242f88488de6c33a966239f Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Wed, 26 Dec 2018 12:05:30 +0100 Subject: [PATCH] add null check for sources --- src/reducers/schema/sourceSchema.js | 2 +- src/selectors/index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/reducers/schema/sourceSchema.js b/src/reducers/schema/sourceSchema.js index 3dc17dd..5f12be9 100644 --- a/src/reducers/schema/sourceSchema.js +++ b/src/reducers/schema/sourceSchema.js @@ -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(''), diff --git a/src/selectors/index.js b/src/selectors/index.js index e9535a5..0ef170d 100644 --- a/src/selectors/index.js +++ b/src/selectors/index.js @@ -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) => ({