Fixed: Task with removed movie causing error

(cherry picked from commit fc6494c569324c839debdb1d08dde23b8f1b8d76)

Closes #9866
pull/9879/head
Mark McDowall 8 months ago committed by Bogdan
parent 28689006fb
commit a75619c8ef

@ -1,12 +1,21 @@
import { createSelector } from 'reselect';
import AppState from 'App/State/AppState';
import Movie from 'Movie/Movie';
function createMultiMoviesSelector(movieIds: number[]) {
return createSelector(
(state: AppState) => state.movies.itemMap,
(state: AppState) => state.movies.items,
(itemMap, allMovies) => {
return movieIds.map((movieId) => allMovies[itemMap[movieId]]);
return movieIds.reduce((acc: Movie[], movieId) => {
const movie = allMovies[itemMap[movieId]];
if (movie) {
acc.push(movie);
}
return acc;
}, []);
}
);
}

Loading…
Cancel
Save