From ca96e11efe502c17ee442218c61f8bf180d02a7a Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Wed, 11 Jun 2025 01:15:49 +0600 Subject: [PATCH] wip --- .../AIChatHistory/AIChatHistory.tsx | 23 ++++++++++--------- .../AIChatHistory/ListChatHistory.tsx | 20 ++++++++++++---- src/queries/chat-history.ts | 2 +- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/AIChatHistory/AIChatHistory.tsx b/src/components/AIChatHistory/AIChatHistory.tsx index 1fca720f0..12982c9f2 100644 --- a/src/components/AIChatHistory/AIChatHistory.tsx +++ b/src/components/AIChatHistory/AIChatHistory.tsx @@ -49,7 +49,7 @@ export function AIChatHistory(props: AIChatHistoryProps) { setIsChatHistoryLoading(false); }, [data, chatHistoryId]); - const isDataLoading = isLoading || isBillingDetailsLoading; + const showGlobalLoader = isLoading || isBillingDetailsLoading; const hasError = chatHistoryError || billingDetailsError; useEffect(() => { @@ -58,24 +58,19 @@ export function AIChatHistory(props: AIChatHistoryProps) { } setIsLoading(false); + setIsChatHistoryLoading(false); }, [hasError]); return (
- {isDataLoading && !hasError && ( + {showGlobalLoader && (
)} - {!isDataLoading && hasError && ( -
- -
- )} - - {!isDataLoading && !hasError && ( + {!showGlobalLoader && ( <> {isPaidUser && ( - {isChatHistoryLoading && ( + {isChatHistoryLoading && !hasError && (
)} - {!isChatHistoryLoading && ( + {!isChatHistoryLoading && hasError && ( +
+ +
+ )} + + {!isChatHistoryLoading && !hasError && ( { + if (!data) { + return; + } + + setIsLoading(false); + }, [data?.pages]); + const groupedChatHistory = useMemo(() => { const today = DateTime.now().startOf('day'); const allHistories = data?.pages?.flatMap((page) => page.data); @@ -85,7 +94,7 @@ export function ListChatHistory(props: ListChatHistoryProps) { if (!isOpen) { return ( -
+
- +
diff --git a/src/queries/chat-history.ts b/src/queries/chat-history.ts index cc4b420fe..4f540c0c4 100644 --- a/src/queries/chat-history.ts +++ b/src/queries/chat-history.ts @@ -87,7 +87,7 @@ export function listChatHistoryOptions( return httpGet('/v1-list-chat-history', { ...(query?.query ? { query: query.query } : {}), ...(pageParam ? { currPage: pageParam } : {}), - perPage: '21', + perPage: '2', }); }, enabled: !!isLoggedIn(),