Skip to content

Commit

Permalink
feat(sanity): use optimistic locking when publishing documents
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 committed May 17, 2024
1 parent 435ae19 commit cf97baa
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const publish: OperationImpl<[], DisabledReason> = {
actionType: 'sanity.action.document.publish',
draftId: idPair.draftId,
publishedId: idPair.publishedId,
// The editor must be able to see the latest state of both the draft document they are
// publishing, and the published document they are choosing to replace. Optimistic
// locking using `ifDraftRevisionId` and `ifPublishedRevisionId` ensures the client and
// server are synchronised.
ifDraftRevisionId: snapshots.draft._rev,
ifPublishedRevisionId: snapshots.published?._rev,
},
],
},
Expand Down

0 comments on commit cf97baa

Please sign in to comment.