Commit 3e0a76da authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Fix async bug of note being updated at the same time

parent fbf241e8
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
discussion: { discussion: {
type: Object, type: Object,
required: false, required: false,
default: () => ({}),
}, },
isEditing: { isEditing: {
type: Boolean, type: Boolean,
...@@ -30,7 +31,6 @@ ...@@ -30,7 +31,6 @@
}, },
data() { data() {
return { return {
initialNote: this.noteBody,
note: this.noteBody, note: this.noteBody,
conflictWhileEditing: false, conflictWhileEditing: false,
isSubmitting: false, isSubmitting: false,
...@@ -72,10 +72,7 @@ ...@@ -72,10 +72,7 @@
}, },
editMyLastNote() { editMyLastNote() {
if (this.note === '') { if (this.note === '') {
const lastNoteInDiscussion = this.getDiscussionLastNote( const lastNoteInDiscussion = this.getDiscussionLastNote(this.discussion);
this.discussion,
this.currentUserId,
);
if (lastNoteInDiscussion) { if (lastNoteInDiscussion) {
eventHub.$emit('enterEditMode', { eventHub.$emit('enterEditMode', {
...@@ -86,7 +83,7 @@ ...@@ -86,7 +83,7 @@
}, },
cancelHandler(shouldConfirm = false) { cancelHandler(shouldConfirm = false) {
// Sends information about confirm message and if the textarea has changed // Sends information about confirm message and if the textarea has changed
this.$emit('cancelFormEdition', shouldConfirm, this.initialNote !== this.note); this.$emit('cancelFormEdition', shouldConfirm, this.noteBody !== this.note);
}, },
}, },
mounted() { mounted() {
...@@ -94,7 +91,7 @@ ...@@ -94,7 +91,7 @@
}, },
watch: { watch: {
noteBody() { noteBody() {
if (this.note === this.initialNote) { if (this.note === this.noteBody) {
this.note = this.noteBody; this.note = this.noteBody;
} else { } else {
this.conflictWhileEditing = true; this.conflictWhileEditing = true;
...@@ -157,3 +154,4 @@ ...@@ -157,3 +154,4 @@
</form> </form>
</div> </div>
</template> </template>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment