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 @@ -585,31 +585,6 @@ userInfoInputArray, threadInfo, }: UseMessageListDataArgs): MessageListData { - const messageInfos = useSelector(messageInfoSelector); - - const containingThread = useSelector(state => { - if (!threadInfo || threadInfo.type !== threadTypes.SIDEBAR) { - return null; - } - return state.messageStore.threads[threadInfo.containingThreadID]; - }); - - const editedText = React.useMemo(() => { - const sourceMessageID = threadInfo?.sourceMessageID; - const threadMessageInfos = (containingThread?.messageIDs ?? []) - .map((messageID: string) => messageInfos[messageID]) - .filter(Boolean) - .filter( - message => - message.type === messageTypes.EDIT_MESSAGE && - message.targetMessageID === sourceMessageID, - ); - if (threadMessageInfos.length === 0) { - return null; - } - return threadMessageInfos[0].text; - }, [containingThread?.messageIDs, messageInfos, threadInfo?.sourceMessageID]); - const pendingSidebarSourceMessageInfo = useSelector(state => { const sourceMessageID = threadInfo?.sourceMessageID; if ( @@ -620,24 +595,14 @@ return null; } const thread = state.messageStore.threads[threadInfo.id]; + const messageInfos = messageInfoSelector(state); const shouldSourceBeAdded = !thread || (thread.startReached && thread.messageIDs.every( id => messageInfos[id]?.type !== messageTypes.SIDEBAR_SOURCE, )); - - if (!shouldSourceBeAdded) { - return null; - } - let result = messageInfos[sourceMessageID]; - if (result && result.type === messageTypes.TEXT && editedText) { - result = { - ...result, - text: editedText, - }; - } - return result; + return shouldSourceBeAdded ? messageInfos[sourceMessageID] : null; }); invariant(