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,
|
enabled: !!searchSpaceId && isSearchMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { activeChats, archivedChats } = useMemo(() => {
|
const threads = useMemo(() => {
|
||||||
if (isSearchMode) {
|
if (isSearchMode) {
|
||||||
return {
|
return (searchData ?? []).filter((thread) => thread.archived === showArchived);
|
||||||
activeChats: (searchData ?? []).filter((t) => !t.archived),
|
|
||||||
archivedChats: (searchData ?? []).filter((t) => t.archived),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!threadsData) return { activeChats: [], archivedChats: [] };
|
if (!threadsData) return [];
|
||||||
|
|
||||||
return {
|
return showArchived ? threadsData.archived_threads : threadsData.threads;
|
||||||
activeChats: threadsData.threads,
|
}, [threadsData, searchData, isSearchMode, showArchived]);
|
||||||
archivedChats: threadsData.archived_threads,
|
|
||||||
};
|
|
||||||
}, [threadsData, searchData, isSearchMode]);
|
|
||||||
|
|
||||||
const threads = showArchived ? archivedChats : activeChats;
|
|
||||||
|
|
||||||
const handleThreadClick = useCallback(
|
const handleThreadClick = useCallback(
|
||||||
(thread: ThreadListItem) => {
|
(thread: ThreadListItem) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue