diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js --- a/lib/selectors/thread-selectors.js +++ b/lib/selectors/thread-selectors.js @@ -200,6 +200,27 @@ }, ); +const containedThreadInfos: (state: BaseAppState<>) => { + +[id: string]: $ReadOnlyArray, +} = createSelector( + threadInfoSelector, + (threadInfos: { +[id: string]: ThreadInfo }) => { + const result = {}; + for (const id in threadInfos) { + const threadInfo = threadInfos[id]; + const { containingThreadID } = threadInfo; + if (containingThreadID === null || containingThreadID === undefined) { + continue; + } + if (result[containingThreadID] === undefined) { + result[containingThreadID] = []; + } + result[containingThreadID].push(threadInfo); + } + return result; + }, +); + function getMostRecentRawMessageInfo( threadInfo: ThreadInfo, messageStore: MessageStore, @@ -451,6 +472,7 @@ entryInfoSelector, currentDaysToEntries, childThreadInfos, + containedThreadInfos, unreadCount, unreadBackgroundCount, otherUsersButNoOtherAdmins,