From 66b0341cfa6fd2a335bb7b1a71b7ef569b50d0cb Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 14 Feb 2026 16:09:10 -0500 Subject: [PATCH] fix: Synthetic 'latest' revision fails to load (#11451) closes #11449 --- app/scenes/Document/components/DataLoader.tsx | 21 ++++++++++++------- app/stores/RevisionsStore.ts | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/scenes/Document/components/DataLoader.tsx b/app/scenes/Document/components/DataLoader.tsx index 0d3d00d689..4775a2766e 100644 --- a/app/scenes/Document/components/DataLoader.tsx +++ b/app/scenes/Document/components/DataLoader.tsx @@ -104,18 +104,23 @@ function DataLoader({ match, children }: Props) { React.useEffect(() => { async function fetchRevision() { - if (revisionId) { - try { - await revisions[revisionId === "latest" ? "fetchLatest" : "fetch"]( - revisionId - ); - } catch (err) { - setError(err); + if (!revisionId) { + return; + } + try { + if (revisionId === "latest") { + if (document?.id) { + await revisions.fetchLatest(document.id); + } + } else { + await revisions.fetch(revisionId); } + } catch (err) { + setError(err); } } void fetchRevision(); - }, [revisions, revisionId]); + }, [revisions, revisionId, document?.id]); React.useEffect(() => { async function fetchViews() { diff --git a/app/stores/RevisionsStore.ts b/app/stores/RevisionsStore.ts index 99ffa31dab..ae61ce9680 100644 --- a/app/stores/RevisionsStore.ts +++ b/app/stores/RevisionsStore.ts @@ -20,7 +20,8 @@ export default class RevisionsStore extends Store { /** * Fetches the latest revision for the given document. * - * @returns A promise that resolves to the latest revision for the given document + * @param documentId - the id of the document to fetch the latest revision for. + * @returns A promise that resolves to the latest revision for the given document. */ fetchLatest = async (documentId: string) => { const res = await client.post(`/revisions.info`, { documentId });