From d8797b4f71c51ac9e42c7a3f2594e75ff924b763 Mon Sep 17 00:00:00 2001 From: Utkarsh-Patel-13 Date: Tue, 22 Jul 2025 17:02:18 -0700 Subject: [PATCH] lazy loading fix for useDocument --- surfsense_web/components/chat_v2/ChatInputGroup.tsx | 3 ++- surfsense_web/hooks/use-documents.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/surfsense_web/components/chat_v2/ChatInputGroup.tsx b/surfsense_web/components/chat_v2/ChatInputGroup.tsx index 6229d1f..44824d2 100644 --- a/surfsense_web/components/chat_v2/ChatInputGroup.tsx +++ b/surfsense_web/components/chat_v2/ChatInputGroup.tsx @@ -42,7 +42,8 @@ const DocumentSelector = React.memo( const [isOpen, setIsOpen] = useState(false); const { documents, loading, isLoaded, fetchDocuments } = useDocuments( - Number(search_space_id) + Number(search_space_id), + true ); const handleOpenChange = useCallback( diff --git a/surfsense_web/hooks/use-documents.ts b/surfsense_web/hooks/use-documents.ts index d38b374..a7d3731 100644 --- a/surfsense_web/hooks/use-documents.ts +++ b/surfsense_web/hooks/use-documents.ts @@ -23,7 +23,7 @@ export type DocumentType = | "LINEAR_CONNECTOR" | "DISCORD_CONNECTOR"; -export function useDocuments(searchSpaceId: number, lazy: boolean = true) { +export function useDocuments(searchSpaceId: number, lazy: boolean = false) { const [documents, setDocuments] = useState([]); const [loading, setLoading] = useState(!lazy); // Don't show loading initially for lazy mode const [error, setError] = useState(null);