diff --git a/packages/sanity/src/core/store/events/getDocumentEvents.test.ts b/packages/sanity/src/core/store/events/getDocumentEvents.test.ts index 930df152bea..98d2072cf11 100644 --- a/packages/sanity/src/core/store/events/getDocumentEvents.test.ts +++ b/packages/sanity/src/core/store/events/getDocumentEvents.test.ts @@ -601,7 +601,7 @@ describe('getDocumentEvents', () => { timestamp: '2024-09-30T14:40:02.837538Z', type: 'document.unpublish', versionId: 'drafts.foo', // Is it correct to use the draft version id here, we are creating a draft by unpublishing the document. - versionRevisionId: 'publish-tx', // + versionRevisionId: 'unpublish-tx', // }, { type: 'document.publishVersion', @@ -763,7 +763,7 @@ describe('getDocumentEvents', () => { timestamp: '2024-09-30T15:04:37.077740Z', author: 'p8xDvUMxC', versionId: undefined, // Draft already exists, a new draft was not created from this tx - versionRevisionId: 'publish-draft-tx', + versionRevisionId: undefined, // Draft already exists, a new draft was not created from this tx, no revisionId to assign releaseId: undefined, }, { @@ -1696,7 +1696,7 @@ describe('getDocumentEvents', () => { author: 'p8xDvUMxC', type: 'document.unpublish', versionId: 'drafts.foo', - versionRevisionId: '7X3uqAgvtaInRcPnekXqDV', + versionRevisionId: 'Cs9MM9AmleFTukvUAmGEQ4', }, { timestamp: '2024-10-01T13:56:19.108493Z', diff --git a/packages/sanity/src/core/store/events/getDocumentEvents.ts b/packages/sanity/src/core/store/events/getDocumentEvents.ts index be08075c488..b3159cd048f 100644 --- a/packages/sanity/src/core/store/events/getDocumentEvents.ts +++ b/packages/sanity/src/core/store/events/getDocumentEvents.ts @@ -172,11 +172,10 @@ function getEventFromTransaction( transaction.documentIDs.length > 1 && transaction.documentIDs.includes(draftId) ? draftId : undefined, - // TODO: Should this be the actual transaction id that created the draft document? - // The revision id of the last edit in the publish document versionRevisionId: - previousTransactions.find((t) => t.documentIDs.includes(publishedId))?.id || - 'not-found', + transaction.documentIDs.length > 1 && transaction.documentIDs.includes(draftId) + ? transaction.id + : undefined, releaseId: getVersionFromId(documentId), } } diff --git a/packages/sanity/src/core/store/events/types.ts b/packages/sanity/src/core/store/events/types.ts index 60383cbc518..24ddaedfbec 100644 --- a/packages/sanity/src/core/store/events/types.ts +++ b/packages/sanity/src/core/store/events/types.ts @@ -247,7 +247,7 @@ export interface UnpublishDocumentEvent extends BaseEvent { /** The version that was created based on it */ versionId: string | undefined - versionRevisionId: string + versionRevisionId?: string releaseId?: string }