From 1b6e9588e83cbf441038264f0a0c5a2c38c86b61 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 2 Feb 2024 00:31:27 +0530 Subject: [PATCH 1/2] Fix new chat error handling (#174) --- src/app/(main)/project/[project_id]/page.tsx | 1 + 1 file changed, 1 insertion(+) 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); } }; From d03ade80253cdc2fbd4a2ca78cd440bd7e81ba68 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 2 Feb 2024 00:32:59 +0530 Subject: [PATCH 2/2] Fix chat list pagination (#175) --- src/components/sidebar/chatSidebar.tsx | 5 +++-- src/utils/hooks/useInfiQuery.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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 = () => {