Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/components/Questions/AnswerInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,24 @@ export default {
const answer = { ...this.answer }
answer.text = value

// Dispatched for creation. Marked as synced
this.$set(this.answer, 'local', false)
const newAnswer = await this.createAnswer(answer)
// Prevent any queued debounced PATCHes from running while creating
this.queue.pause()
try {
// Dispatched for creation. Marked as synced
this.$set(this.answer, 'local', false)
const newAnswer = await this.createAnswer(answer)

// Forward changes, but use current answer.text to avoid erasing
// any in-between changes while creating the answer
newAnswer.text = this.$refs.input.value
this.localText = ''
// Forward changes, but use current answer.text to avoid erasing
// any in-between changes while creating the answer
newAnswer.text = this.$refs.input.value
this.localText = ''

this.$emit('create-answer', this.index, newAnswer)
this.$emit('create-answer', this.index, newAnswer)
} finally {
// Clear pending update tasks (stale PATCHes) before resuming processing
this.queue.clear()
this.queue.start()
}
},

/**
Expand Down
Loading