Skip to content

Commit

Permalink
Fixed: Task with removed movie causing error
Browse files Browse the repository at this point in the history
(cherry picked from commit fc6494c569324c839debdb1d08dde23b8f1b8d76)

Closes #9866
  • Loading branch information
markus101 authored and mynameisbogdan committed Mar 28, 2024
1 parent 2868900 commit a75619c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/Store/Selectors/createMultiMoviesSelector.ts
Original file line number Diff line number Diff line change
@@ -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;
}, []);
}
);
}
Expand Down

0 comments on commit a75619c

Please sign in to comment.