mirror of
https://github.com/Readarr/Readarr
synced 2025-12-06 16:32:51 +01:00
Fixed: Task with removed author causing error
(cherry picked from commit fc6494c569324c839debdb1d08dde23b8f1b8d76) Closes #3376
This commit is contained in:
parent
2b100d0f72
commit
4fb62c072a
1 changed files with 10 additions and 1 deletions
|
|
@ -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;
|
||||||
|
}, []);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue