mirror of
https://github.com/outline/outline.git
synced 2026-11-26 07:33:19 +03:00
fix: Prefetch document structure for starred docs (#11355)
* fix: Prefetch document structure for starred docs * fix: Disclosure does not work correctly
This commit is contained in:
1 parent
e1598c08d8
commit
7cd00f3465
2 files changed
+15
-9
No files matched your search
@@ -139,7 +139,7 @@ function SidebarLink(
|
||||
ev.stopPropagation();
|
||||
onDisclosureClick?.(ev);
|
||||
},
|
||||
[onDisclosureClick]
|
||||
[onDisclosureClick, hasDisclosure]
|
||||
);
|
||||
|
||||
const DisclosureComponent = icon ? HiddenDisclosure : Disclosure;
|
||||
|
||||
@@ -63,7 +63,7 @@ type StarredCollectionLinkProps = {
|
||||
reorderStarProps: any;
|
||||
};
|
||||
|
||||
function StarredDocumentLink({
|
||||
const StarredDocumentLink = observer(function StarredDocumentLink({
|
||||
star,
|
||||
documentId,
|
||||
expanded,
|
||||
@@ -156,9 +156,9 @@ function StarredDocumentLink({
|
||||
</SidebarContext.Provider>
|
||||
</ActionContextProvider>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function StarredCollectionLink({
|
||||
const StarredCollectionLink = observer(function StarredCollectionLink({
|
||||
star,
|
||||
collection,
|
||||
sidebarContext,
|
||||
@@ -185,7 +185,7 @@ function StarredCollectionLink({
|
||||
<Relative>{cursor}</Relative>
|
||||
</SidebarContext.Provider>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user