Changeset View
Changeset View
Standalone View
Standalone View
web/chat/chat-thread-list.react.js
Show All 25 Lines | function ChatThreadList(): React.Node { | ||||
const onClickNewThread = useOnClickNewThread(); | const onClickNewThread = useOnClickNewThread(); | ||||
const isThreadCreation = useSelector( | const isThreadCreation = useSelector( | ||||
state => state.navInfo.chatMode === 'create', | state => state.navInfo.chatMode === 'create', | ||||
); | ); | ||||
const isBackground = activeTab === 'Background'; | const isBackground = activeTab === 'Background'; | ||||
const communityID = useSelector(state => state.communityPickerStore.chat); | |||||
const threadComponents: React.Node[] = React.useMemo(() => { | const threadComponents: React.Node[] = React.useMemo(() => { | ||||
const threads = threadList.map(item => ( | const threads = threadList | ||||
<ChatThreadListItem item={item} key={item.threadInfo.id} /> | .filter( | ||||
)); | item => | ||||
!communityID || | |||||
item.threadInfo.community === communityID || | |||||
item.threadInfo.id === communityID, | |||||
) | |||||
.map(item => <ChatThreadListItem item={item} key={item.threadInfo.id} />); | |||||
if (threads.length === 0 && isBackground) { | if (threads.length === 0 && isBackground) { | ||||
threads.push(<EmptyItem key="emptyItem" />); | threads.push(<EmptyItem key="emptyItem" />); | ||||
} | } | ||||
return threads; | return threads; | ||||
}, [threadList, isBackground]); | }, [threadList, isBackground, communityID]); | ||||
return ( | return ( | ||||
<> | <> | ||||
<div className={css.threadListContainer}> | <div className={css.threadListContainer}> | ||||
<Search | <Search | ||||
onChangeText={setSearchText} | onChangeText={setSearchText} | ||||
searchText={searchText} | searchText={searchText} | ||||
placeholder="Search chats" | placeholder="Search chats" | ||||
Show All 26 Lines |