Fixed: Task with removed series causing error

This commit is contained in:
Mark McDowall 2024-03-23 21:42:54 -07:00 committed by Mark McDowall
parent c403b2cdd5
commit fc6494c569
1 changed files with 10 additions and 1 deletions

View File

@ -1,12 +1,21 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import AppState from 'App/State/AppState'; import AppState from 'App/State/AppState';
import Series from 'Series/Series';
function createMultiSeriesSelector(seriesIds: number[]) { function createMultiSeriesSelector(seriesIds: number[]) {
return createSelector( return createSelector(
(state: AppState) => state.series.itemMap, (state: AppState) => state.series.itemMap,
(state: AppState) => state.series.items, (state: AppState) => state.series.items,
(itemMap, allSeries) => { (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;
}, []);
} }
); );
} }