parent
a2d505c795
commit
f5692d6cf1
@ -1,6 +1,8 @@
|
||||
import AppSectionState from 'App/State/AppSectionState';
|
||||
import MovieCollection from 'typings/MovieCollection';
|
||||
|
||||
type MovieCollectionAppState = AppSectionState<MovieCollection>;
|
||||
interface MovieCollectionAppState extends AppSectionState<MovieCollection> {
|
||||
itemMap: Record<number, number>;
|
||||
}
|
||||
|
||||
export default MovieCollectionAppState;
|
||||
|
@ -1,17 +0,0 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
function createCollectionSelector() {
|
||||
return createSelector(
|
||||
(state, { collectionId }) => collectionId,
|
||||
(state) => state.movieCollections.itemMap,
|
||||
(state) => state.movieCollections.items,
|
||||
(collectionId, itemMap, allCollections) => {
|
||||
if (allCollections && itemMap && collectionId in itemMap) {
|
||||
return allCollections[itemMap[collectionId]];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createCollectionSelector;
|
@ -0,0 +1,17 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createCollectionSelector() {
|
||||
return createSelector(
|
||||
(_: AppState, { collectionId }: { collectionId: number }) => collectionId,
|
||||
(state: AppState) => state.movieCollections.itemMap,
|
||||
(state: AppState) => state.movieCollections.items,
|
||||
(collectionId, itemMap, allCollections) => {
|
||||
return allCollections && itemMap && collectionId in itemMap
|
||||
? allCollections[itemMap[collectionId]]
|
||||
: undefined;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createCollectionSelector;
|
Loading…
Reference in new issue