fix(documents): keep feature-flags query out of realtime invalidation

The feature-flags query previously sat at ['documents', 'feature-flags'],
which the hub's useRealtimeInvalidation([['documents']]) registration
matched via TanStack's default prefix matching. Every document socket
event refetched the flag, silently defeating the 5-minute staleTime.
Move the key to ['documents-feature-flags'] so it sits outside the
prefix; document events no longer trigger a flag refetch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 12:34:51 +02:00
parent f8fcb8d8ad
commit 8e06d4549d

View File

@@ -120,11 +120,11 @@ export function DocumentsHub({ portSlug, initialTab = 'all' }: DocumentsHubProps
}); });
const { data: flagsResp } = useQuery<{ data: { showExpiredTab: boolean } }>({ const { data: flagsResp } = useQuery<{ data: { showExpiredTab: boolean } }>({
queryKey: ['documents', 'feature-flags'], queryKey: ['documents-feature-flags'],
queryFn: () => apiFetch('/api/v1/documents/feature-flags'), queryFn: () => apiFetch('/api/v1/documents/feature-flags'),
staleTime: 5 * 60 * 1000, staleTime: 5 * 60 * 1000,
}); });
const showExpiredTab = flagsResp?.data.showExpiredTab ?? true; const showExpiredTab = flagsResp?.data?.showExpiredTab ?? true;
useRealtimeInvalidation({ useRealtimeInvalidation({
'document:created': [['documents']], 'document:created': [['documents']],
@@ -282,7 +282,9 @@ export function DocumentsHub({ portSlug, initialTab = 'all' }: DocumentsHubProps
}} }}
> >
<TabsList> <TabsList>
{documentsHubTabs.filter((t) => t !== 'expired' || showExpiredTab).map((t) => ( {documentsHubTabs
.filter((t) => t !== 'expired' || showExpiredTab)
.map((t) => (
<TabsTrigger key={t} value={t}> <TabsTrigger key={t} value={t}>
{TAB_LABELS[t]} {TAB_LABELS[t]}
{t !== 'all' && counts[t] > 0 ? ( {t !== 'all' && counts[t] > 0 ? (