FIX: Predict draftSequence on draft save (#15390)

The new draft sequence is returned after the draft is saved and usually
it is the old draft sequence plus one and this way the new draft
sequence can be predicted.

Sometimes drafts are saved at odd times or the request is slower than
usual which can create a race condition. This prediction can fix this
problem.
This commit is contained in:
Bianca Nenciu 2021-12-22 17:17:32 +02:00 committed by GitHub
parent b0dd1b1200
commit 28400f1cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1223,16 +1223,19 @@ const Composer = RestModel.extend({
data.originalText = this.originalText;
}
const draftSequence = this.draftSequence;
this.set("draftSequence", this.draftSequence + 1);
return Draft.save(
this.draftKey,
this.draftSequence,
draftSequence,
data,
this.messageBus.clientId,
{ forceSave: this.draftForceSave }
)
.then((result) => {
if (result.draft_sequence) {
this.draftSequence = result.draft_sequence;
this.set("draftSequence", result.draft_sequence);
}
if (result.conflict_user) {
this.setProperties({