mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-20 21:54:25 -04:00
4fb62c072a
(cherry picked from commit fc6494c569324c839debdb1d08dde23b8f1b8d76) Closes #3376
24 lines
600 B
TypeScript
24 lines
600 B
TypeScript
import { createSelector } from 'reselect';
|
|
import AppState from 'App/State/AppState';
|
|
import Author from 'Author/Author';
|
|
|
|
function createMultiAuthorsSelector(authorIds: number[]) {
|
|
return createSelector(
|
|
(state: AppState) => state.authors.itemMap,
|
|
(state: AppState) => state.authors.items,
|
|
(itemMap, allAuthors) => {
|
|
return authorIds.reduce((acc: Author[], authorId) => {
|
|
const author = allAuthors[itemMap[authorId]];
|
|
|
|
if (author) {
|
|
acc.push(author);
|
|
}
|
|
|
|
return acc;
|
|
}, []);
|
|
}
|
|
);
|
|
}
|
|
|
|
export default createMultiAuthorsSelector;
|