Skip to content

Commit

Permalink
fix(sanity): remove ifDraftRevisionId optimistic lock usage when pu…
Browse files Browse the repository at this point in the history
…blishing documents

Co-authored-by: Bjørge Næss <bjoerge@gmail.com>
  • Loading branch information
juice49 and bjoerge committed Jun 18, 2024
1 parent 17d0bbf commit 3064705
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Object {
"actions": Object {
"actionType": "sanity.action.document.publish",
"draftId": "drafts.my-id",
"ifDraftRevisionId": "exampleRev",
"ifPublishedRevisionId": "exampleRev",
"publishedId": "my-id",
},
Expand Down Expand Up @@ -37,7 +36,6 @@ Object {
"actions": Object {
"actionType": "sanity.action.document.publish",
"draftId": "drafts.my-id",
"ifDraftRevisionId": "exampleRev",
"ifPublishedRevisionId": undefined,
"publishedId": "my-id",
},
Expand Down Expand Up @@ -65,7 +63,6 @@ Object {
"actions": Object {
"actionType": "sanity.action.document.publish",
"draftId": "drafts.my-id",
"ifDraftRevisionId": "exampleRev",
"ifPublishedRevisionId": undefined,
"publishedId": "my-id",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ 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,
// Optimistic locking using `ifPublishedRevisionId` ensures that concurrent publish action
// invocations do not override each other.
//
// Note: for custom publish actions, `snapshots.draft._rev` may be stale, which means the
// `ifDraftRevisionId` optimistic lock cannot currently be used.
ifPublishedRevisionId: snapshots.published?._rev,
},
{
Expand Down

0 comments on commit 3064705

Please sign in to comment.