From 4fb62c072a4ec872a9b1e24741ab7bb331313dc4 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 23 Mar 2024 21:42:54 -0700 Subject: [PATCH] Fixed: Task with removed author causing error (cherry picked from commit fc6494c569324c839debdb1d08dde23b8f1b8d76) Closes #3376 --- .../src/Store/Selectors/createMultiAuthorsSelector.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/Store/Selectors/createMultiAuthorsSelector.ts b/frontend/src/Store/Selectors/createMultiAuthorsSelector.ts index 1070dfe7f..cf5086276 100644 --- a/frontend/src/Store/Selectors/createMultiAuthorsSelector.ts +++ b/frontend/src/Store/Selectors/createMultiAuthorsSelector.ts @@ -1,12 +1,21 @@ 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.map((authorId) => allAuthors[itemMap[authorId]]); + return authorIds.reduce((acc: Author[], authorId) => { + const author = allAuthors[itemMap[authorId]]; + + if (author) { + acc.push(author); + } + + return acc; + }, []); } ); }