From fc6494c569324c839debdb1d08dde23b8f1b8d76 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 23 Mar 2024 21:42:54 -0700 Subject: [PATCH] Fixed: Task with removed series causing error --- .../src/Store/Selectors/createMultiSeriesSelector.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/Store/Selectors/createMultiSeriesSelector.ts b/frontend/src/Store/Selectors/createMultiSeriesSelector.ts index 119ccd1ee..fa8235c45 100644 --- a/frontend/src/Store/Selectors/createMultiSeriesSelector.ts +++ b/frontend/src/Store/Selectors/createMultiSeriesSelector.ts @@ -1,12 +1,21 @@ import { createSelector } from 'reselect'; import AppState from 'App/State/AppState'; +import Series from 'Series/Series'; function createMultiSeriesSelector(seriesIds: number[]) { return createSelector( (state: AppState) => state.series.itemMap, (state: AppState) => state.series.items, (itemMap, allSeries) => { - return seriesIds.map((seriesId) => allSeries[itemMap[seriesId]]); + return seriesIds.reduce((acc: Series[], seriesId) => { + const series = allSeries[itemMap[seriesId]]; + + if (series) { + acc.push(series); + } + + return acc; + }, []); } ); }