|
|
@ -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 Movie from 'Movie/Movie';
|
|
|
|
|
|
|
|
|
|
|
|
function createMultiMoviesSelector(movieIds: number[]) {
|
|
|
|
function createMultiMoviesSelector(movieIds: number[]) {
|
|
|
|
return createSelector(
|
|
|
|
return createSelector(
|
|
|
|
(state: AppState) => state.movies.itemMap,
|
|
|
|
(state: AppState) => state.movies.itemMap,
|
|
|
|
(state: AppState) => state.movies.items,
|
|
|
|
(state: AppState) => state.movies.items,
|
|
|
|
(itemMap, allMovies) => {
|
|
|
|
(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;
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|