- Add searchMessages, toggleBookmark, getBookmarks, branchConversation, listBranches, exportConversation to chatApi - Create useChatSearch hook with debounced FTS, placeholderData, 30s staleTime - Create useChatBookmarks and useToggleBookmark with cache invalidation for bookmarks and search queries
12 lines
419 B
TypeScript
12 lines
419 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { chatApi } from "../api/chat";
|
|
|
|
export function useChatSearch(companyId: string | null, query: string) {
|
|
return useQuery({
|
|
queryKey: ["chat", "search", companyId, query],
|
|
queryFn: () => chatApi.searchMessages(companyId!, query),
|
|
enabled: !!companyId && query.trim().length >= 2,
|
|
placeholderData: (prev) => prev,
|
|
staleTime: 30_000,
|
|
});
|
|
}
|