From 8cbc17e388e464fda64017b4a3b5f33b173df94c Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Thu, 17 Jan 2019 11:18:22 -0500 Subject: [PATCH] Return narratives in original order --- src/selectors/index.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/selectors/index.js b/src/selectors/index.js index e6562ad..53cae3f 100644 --- a/src/selectors/index.js +++ b/src/selectors/index.js @@ -145,11 +145,6 @@ export const selectNarratives = createSelector( steps.sort(compareTimestamp) - // steps.forEach((step, i) => { - // narratives[key].byId[step.id].next = (i < steps.length - 2) ? steps[i + 1] : null - // narratives[key].byId[step.id].prev = (i > 0) ? steps[i - 1] : null - // }) - if (narrativesMeta.find(n => n.id === key)) { narratives[key] = { ...narrativesMeta.find(n => n.id === key), @@ -158,7 +153,9 @@ export const selectNarratives = createSelector( } }) - return Object.values(narratives) + // Return narratives in original order + // + filter those that are undefined + return narrativesMeta.map(n => narratives[n.id]).filter(d => d); }) /** Aggregate information about the narrative and the current step into