diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js --- a/lib/selectors/chat-selectors.js +++ b/lib/selectors/chat-selectors.js @@ -214,38 +214,22 @@ return React.useMemo( () => - getChatThreadItems( - threadInfos, - messageStore, - messageInfos, - sidebarInfos, - filterFunction, - ), + _flow( + _filter(filterFunction), + _map((threadInfo: ThreadInfo): ChatThreadItem => + createChatThreadItem( + threadInfo, + messageStore, + messageInfos, + sidebarInfos[threadInfo.id], + ), + ), + _orderBy('lastUpdatedTimeIncludingSidebars')('desc'), + )(threadInfos), [messageInfos, messageStore, sidebarInfos, filterFunction, threadInfos], ); } -function getChatThreadItems( - threadInfos: { +[id: string]: ThreadInfo }, - messageStore: MessageStore, - messageInfos: { +[id: string]: ?MessageInfo }, - sidebarInfos: { +[id: string]: $ReadOnlyArray }, - filterFunction: (threadInfo: ?(ThreadInfo | RawThreadInfo)) => boolean, -): $ReadOnlyArray { - return _flow( - _filter(filterFunction), - _map((threadInfo: ThreadInfo): ChatThreadItem => - createChatThreadItem( - threadInfo, - messageStore, - messageInfos, - sidebarInfos[threadInfo.id], - ), - ), - _orderBy('lastUpdatedTimeIncludingSidebars')('desc'), - )(threadInfos); -} - export type RobotextChatMessageInfoItem = { +itemType: 'message', +messageInfoType: 'robotext',