mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
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:
parent
b0dd1b1200
commit
28400f1cbe
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue
Block a user