diff --git a/src/app/(main)/project/[project_id]/page.tsx b/src/app/(main)/project/[project_id]/page.tsx index b19df1af..c9a09e17 100644 --- a/src/app/(main)/project/[project_id]/page.tsx +++ b/src/app/(main)/project/[project_id]/page.tsx @@ -48,6 +48,7 @@ export default function Chat(params: { params: { project_id: string } }) { }); if (message.stop) setIsTyping(false); if (message.error) { + setChatMessage(""); setIsTyping(false); } }; diff --git a/src/components/sidebar/chatSidebar.tsx b/src/components/sidebar/chatSidebar.tsx index c11708d7..91578dc2 100644 --- a/src/components/sidebar/chatSidebar.tsx +++ b/src/components/sidebar/chatSidebar.tsx @@ -23,14 +23,15 @@ export default function ChatSideBar(props: { project_id?: string }) { const debouncedSearchQuery = useDebounce(searchQuery, 1000); const chatsQuery = useInfiQuery({ queryKey: ["search", debouncedSearchQuery], - queryFn: ({ pageParam = 0 }) => { - return API.chat.list( + queryFn: async ({ pageParam = 0 }) => { + const res = await API.chat.list( project_id || "", { offset: pageParam, search: debouncedSearchQuery }, ); + return { ...res, offset: pageParam }; }, enabled: !!project_id, }, diff --git a/src/utils/hooks/useInfiQuery.tsx b/src/utils/hooks/useInfiQuery.tsx index 4bee2c0d..e2eae2f8 100644 --- a/src/utils/hooks/useInfiQuery.tsx +++ b/src/utils/hooks/useInfiQuery.tsx @@ -20,7 +20,7 @@ export const useInfiQuery: (options: InfiQueryProps) => InfiQueryResult = ( queryKey, queryFn, initialPageParam: 0, - getNextPageParam: (lastPage: any) => lastPage.has_next ? lastPage.offset + (fetchLimit || 10) : undefined, + getNextPageParam: (lastPage: any) => lastPage.has_next ? (lastPage.offset ?? 0) + (fetchLimit ?? 10) : undefined, }); const loadMore = () => {