You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1010 B
32 lines
1010 B
import { createSelector } from 'reselect';
|
|
import AppState from 'App/State/AppState';
|
|
import Movie from 'Movie/Movie';
|
|
import ImportList from 'typings/ImportList';
|
|
import MovieCollection from 'typings/MovieCollection';
|
|
import createAllMoviesSelector from './createAllMoviesSelector';
|
|
|
|
function createProfileInUseSelector(profileProp: string) {
|
|
return createSelector(
|
|
(_: AppState, { id }: { id: number }) => id,
|
|
createAllMoviesSelector(),
|
|
(state: AppState) => state.settings.importLists.items,
|
|
(state: AppState) => state.movieCollections.items,
|
|
(id, movies, lists, collections) => {
|
|
if (!id) {
|
|
return false;
|
|
}
|
|
|
|
return (
|
|
movies.some((m) => m[profileProp as keyof Movie] === id) ||
|
|
lists.some((list) => list[profileProp as keyof ImportList] === id) ||
|
|
collections.some(
|
|
(collection) =>
|
|
collection[profileProp as keyof MovieCollection] === id
|
|
)
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
export default createProfileInUseSelector;
|