fix: Synthetic 'latest' revision fails to load (#11451)

closes #11449
This commit is contained in:
Tom Moor
2026-02-14 16:09:10 -05:00
committed by GitHub
parent 057d57e21a
commit 66b0341cfa
2 changed files with 15 additions and 9 deletions
+13 -8
View File
@@ -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() {
+2 -1
View File
@@ -20,7 +20,8 @@ export default class RevisionsStore extends Store<Revision> {
/**
* 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 });