Commit 9cd5ca2f authored by Fatih Acet's avatar Fatih Acet

Fix autosave in noteable discussion.

parent 5f7a81c4
<script>
import $ from 'jquery';
import { mapState, mapGetters, mapActions } from 'vuex';
import createFlash from '~/flash';
import { s__ } from '~/locale';
import noteForm from '../../notes/components/note_form.vue';
import { getNoteFormData } from '../store/utils';
import autosave from '../../notes/mixins/autosave';
import { DIFF_NOTE_TYPE, NOTE_TYPE } from '../constants';
import { DIFF_NOTE_TYPE } from '../constants';
export default {
components: {
......@@ -42,21 +41,21 @@ export default {
},
mounted() {
if (this.isLoggedIn) {
const noteableData = this.noteableData;
const keys = [
noteableData.diff_head_sha,
this.noteableData.diff_head_sha,
DIFF_NOTE_TYPE,
noteableData.source_project_id,
this.noteableData.source_project_id,
this.line.lineCode,
];
this.initAutoSave(noteableData, keys);
this.initAutoSave(this.noteableData, keys);
}
},
methods: {
...mapActions('diffs', ['cancelCommentForm']),
...mapActions(['saveNote', 'refetchDiscussionById']),
handleCancelCommentForm() {
// eslint-disable-next-line no-alert
if (!window.confirm('Are you sure you want to cancel creating this comment?')) {
return;
}
......
......@@ -144,20 +144,18 @@ export default {
return this.isDiffDiscussion ? '' : 'card discussion-wrapper';
},
},
mounted() {
watch: {
isReplying() {
if (this.isReplying) {
this.initAutoSave(this.transformedDiscussion);
}
},
updated() {
if (this.isReplying) {
if (!this.autosave) {
this.initAutoSave(this.transformedDiscussion);
this.$nextTick(() => {
// Pass an extra key to separate reply and note edit forms
this.initAutoSave(this.transformedDiscussion, ['Reply']);
});
} else {
this.setAutoSave();
}
this.autosave.dispose();
}
},
},
created() {
this.resolveDiscussionsSvg = resolveDiscussionsSvg;
this.nextDiscussionsSvg = nextDiscussionsSvg;
......@@ -420,7 +418,8 @@ Please check your network connection and try again.`;
:is-editing="false"
save-button-title="Comment"
@handleFormUpdate="saveReply"
@cancelForm="cancelReplyForm" />
@cancelForm="cancelReplyForm"
/>
<note-signed-out-widget v-if="!canReply" />
</div>
</div>
......
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