mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-08 22:22:17 +02:00
refactor(chats): simplify chat filtering logic in AllChatsSidebar
This commit is contained in:
parent
29d4fde2c0
commit
865e22aaa4
1 changed files with 5 additions and 13 deletions
|
|
@ -113,23 +113,15 @@ function AllChatsContent({ searchSpaceId, className }: AllChatsContentProps) {
|
|||
enabled: !!searchSpaceId && isSearchMode,
|
||||
});
|
||||
|
||||
const { activeChats, archivedChats } = useMemo(() => {
|
||||
const threads = useMemo(() => {
|
||||
if (isSearchMode) {
|
||||
return {
|
||||
activeChats: (searchData ?? []).filter((t) => !t.archived),
|
||||
archivedChats: (searchData ?? []).filter((t) => t.archived),
|
||||
};
|
||||
return (searchData ?? []).filter((thread) => thread.archived === showArchived);
|
||||
}
|
||||
|
||||
if (!threadsData) return { activeChats: [], archivedChats: [] };
|
||||
if (!threadsData) return [];
|
||||
|
||||
return {
|
||||
activeChats: threadsData.threads,
|
||||
archivedChats: threadsData.archived_threads,
|
||||
};
|
||||
}, [threadsData, searchData, isSearchMode]);
|
||||
|
||||
const threads = showArchived ? archivedChats : activeChats;
|
||||
return showArchived ? threadsData.archived_threads : threadsData.threads;
|
||||
}, [threadsData, searchData, isSearchMode, showArchived]);
|
||||
|
||||
const handleThreadClick = useCallback(
|
||||
(thread: ThreadListItem) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue