diff --git a/web/chat/chat-thread-list.react.js b/web/chat/chat-thread-list.react.js index ac69d5ece..858aa7249 100644 --- a/web/chat/chat-thread-list.react.js +++ b/web/chat/chat-thread-list.react.js @@ -1,76 +1,83 @@ // @flow import invariant from 'invariant'; import * as React from 'react'; import { emptyItemText } from 'lib/shared/thread-utils.js'; import ChatThreadListItem from './chat-thread-list-item.react.js'; import css from './chat-thread-list.css'; import { ThreadListContext } from './thread-list-provider.js'; import BackgroundIllustration from '../assets/background-illustration.react.js'; import Button from '../components/button.react.js'; import Search from '../components/search.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { useOnClickNewThread } from '../selectors/thread-selectors.js'; function ChatThreadList(): React.Node { const threadListContext = React.useContext(ThreadListContext); invariant( threadListContext, 'threadListContext should be set in ChatThreadList', ); const { activeTab, threadList, setSearchText, searchText } = threadListContext; const onClickNewThread = useOnClickNewThread(); const isThreadCreation = useSelector( state => state.navInfo.chatMode === 'create', ); const isBackground = activeTab === 'Background'; + const communityID = useSelector(state => state.communityPickerStore.chat); + const threadComponents: React.Node[] = React.useMemo(() => { - const threads = threadList.map(item => ( - - )); + const threads = threadList + .filter( + item => + !communityID || + item.threadInfo.community === communityID || + item.threadInfo.id === communityID, + ) + .map(item => ); if (threads.length === 0 && isBackground) { threads.push(); } return threads; - }, [threadList, isBackground]); + }, [threadList, isBackground, communityID]); return ( <>
{threadComponents}
); } function EmptyItem() { return (
{emptyItemText}
); } export default ChatThreadList;