From 7cd00f3465bb7b279c6c07bd341ede5d348fc324 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 3 Feb 2026 20:40:03 -0500 Subject: [PATCH] fix: Prefetch document structure for starred docs (#11355) * fix: Prefetch document structure for starred docs * fix: Disclosure does not work correctly --- .../Sidebar/components/SidebarLink.tsx | 2 +- .../Sidebar/components/StarredLink.tsx | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/components/Sidebar/components/SidebarLink.tsx b/app/components/Sidebar/components/SidebarLink.tsx index 2eddc065ed..73c812dfc5 100644 --- a/app/components/Sidebar/components/SidebarLink.tsx +++ b/app/components/Sidebar/components/SidebarLink.tsx @@ -139,7 +139,7 @@ function SidebarLink( ev.stopPropagation(); onDisclosureClick?.(ev); }, - [onDisclosureClick] + [onDisclosureClick, hasDisclosure] ); const DisclosureComponent = icon ? HiddenDisclosure : Disclosure; diff --git a/app/components/Sidebar/components/StarredLink.tsx b/app/components/Sidebar/components/StarredLink.tsx index de4e35c0f1..00081a3ed5 100644 --- a/app/components/Sidebar/components/StarredLink.tsx +++ b/app/components/Sidebar/components/StarredLink.tsx @@ -63,7 +63,7 @@ type StarredCollectionLinkProps = { reorderStarProps: any; }; -function StarredDocumentLink({ +const StarredDocumentLink = observer(function StarredDocumentLink({ star, documentId, expanded, @@ -156,9 +156,9 @@ function StarredDocumentLink({ ); -} +}); -function StarredCollectionLink({ +const StarredCollectionLink = observer(function StarredCollectionLink({ star, collection, sidebarContext, @@ -185,7 +185,7 @@ function StarredCollectionLink({ {cursor} ); -} +}); function StarredLink({ star }: Props) { const theme = useTheme(); @@ -240,10 +240,16 @@ function StarredLink({ star }: Props) { [] ); - const handlePrefetch = React.useCallback( - () => documentId && documents.prefetchDocument(documentId), - [documents, documentId] - ); + const handlePrefetch = React.useCallback(() => { + if (documentId) { + void documents.prefetchDocument(documentId); + const document = documents.get(documentId); + const documentCollection = document?.collectionId + ? collections.get(document.collectionId) + : undefined; + void documentCollection?.fetchDocuments(); + } + }, [documents, documentId, collections]); const getIndex = () => { const next = star?.next();