|
|
@ -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 Author from 'Author/Author';
|
|
|
|
|
|
|
|
|
|
|
|
function createMultiAuthorsSelector(authorIds: number[]) {
|
|
|
|
function createMultiAuthorsSelector(authorIds: number[]) {
|
|
|
|
return createSelector(
|
|
|
|
return createSelector(
|
|
|
|
(state: AppState) => state.authors.itemMap,
|
|
|
|
(state: AppState) => state.authors.itemMap,
|
|
|
|
(state: AppState) => state.authors.items,
|
|
|
|
(state: AppState) => state.authors.items,
|
|
|
|
(itemMap, allAuthors) => {
|
|
|
|
(itemMap, allAuthors) => {
|
|
|
|
return authorIds.map((authorId) => allAuthors[itemMap[authorId]]);
|
|
|
|
return authorIds.reduce((acc: Author[], authorId) => {
|
|
|
|
|
|
|
|
const author = allAuthors[itemMap[authorId]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (author) {
|
|
|
|
|
|
|
|
acc.push(author);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|