From 8eaa4e618ddf0b33aef539ba5da1ef54aab4b6bf Mon Sep 17 00:00:00 2001 From: SohamBhattacharjee2003 <125297948+SohamBhattacharjee2003@users.noreply.github.com> Date: Fri, 3 Apr 2026 14:42:44 +0530 Subject: [PATCH] perf(hooks): normalize query keys and add placeholderData to optimize thread loading --- .../components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx | 1 + surfsense_web/components/onboarding-tour.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx index 1bc773374..63d69ecd1 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx @@ -109,6 +109,7 @@ export function AllPrivateChatsSidebarContent({ queryKey: ["all-threads", searchSpaceId], queryFn: () => fetchThreads(Number(searchSpaceId)), enabled: !!searchSpaceId && !isSearchMode, + placeholderData: () => queryClient.getQueryData(["threads", searchSpaceId, { limit: 40 }]), }); const { diff --git a/surfsense_web/components/onboarding-tour.tsx b/surfsense_web/components/onboarding-tour.tsx index 1c52169cb..d35799137 100644 --- a/surfsense_web/components/onboarding-tour.tsx +++ b/surfsense_web/components/onboarding-tour.tsx @@ -439,8 +439,8 @@ export function OnboardingTour() { // Fetch threads data const { data: threadsData } = useQuery({ - queryKey: ["threads", searchSpaceId, { limit: 1 }], - queryFn: () => fetchThreads(Number(searchSpaceId), 1), // Only need to check if any exist + queryKey: ["threads", searchSpaceId, { limit: 40 }], // Same key as layout + queryFn: () => fetchThreads(Number(searchSpaceId), 40), enabled: !!searchSpaceId, });