diff --git a/web/chat/chat-thread-list.react.js b/web/chat/chat-thread-list.react.js index 74044725d..eabbe3beb 100644 --- a/web/chat/chat-thread-list.react.js +++ b/web/chat/chat-thread-list.react.js @@ -1,38 +1,47 @@ // @flow import * as React from 'react'; +import { threadInChatList } from 'lib/shared/thread-utils'; import type { ThreadInfo } from 'lib/types/thread-types'; import { useSelector } from '../redux/redux-utils'; import { webChatListData } from '../selectors/chat-selectors'; import ChatThreadListItem from './chat-thread-list-item.react'; type Props = {| +filterThreads: (threadItem: ThreadInfo) => boolean, +setModal: (modal: ?React.Node) => void, +emptyItem?: React.ComponentType<{||}>, |}; function ChatThreadList(props: Props) { const { filterThreads, setModal, emptyItem } = props; + const activeChatThreadID = useSelector( + (state) => state.navInfo.activeChatThreadID, + ); const chatListData = useSelector(webChatListData); const listData: React.Node[] = React.useMemo(() => { const threads = chatListData - .filter((item) => filterThreads(item.threadInfo)) + .filter( + (item) => + filterThreads(item.threadInfo) || + (item.threadInfo.id === activeChatThreadID && + !threadInChatList(item.threadInfo)), + ) .map((item) => ( )); if (threads.length === 0 && emptyItem) { const EmptyItem = emptyItem; threads.push(); } return threads; - }, [chatListData, emptyItem, filterThreads, setModal]); + }, [activeChatThreadID, chatListData, emptyItem, filterThreads, setModal]); return
{listData}
; } export default ChatThreadList;