diff options
Diffstat (limited to 'app/assets/javascripts/notes/stores')
-rw-r--r-- | app/assets/javascripts/notes/stores/actions.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/notes/stores/mutations.js | 38 |
2 files changed, 23 insertions, 17 deletions
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 37986c8a02d..2c60b5ee84a 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -167,7 +167,7 @@ export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes) if (discussion) { commit(types.ADD_NEW_REPLY_TO_DISCUSSION, note); - } else if (note.type === constants.DIFF_NOTE) { + } else if (note.type === constants.DIFF_NOTE && !note.base_discussion) { debouncedFetchDiscussions(state.currentlyFetchingDiscussions); } else { commit(types.ADD_NEW_NOTE, note); diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index 6c11d53dba3..7cc619ec1c5 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -11,24 +11,30 @@ export default { const isDiscussion = type === constants.DISCUSSION_NOTE || type === constants.DIFF_NOTE; if (!exists) { - const noteData = { - expanded: true, - id: discussion_id, - individual_note: !isDiscussion, - notes: [note], - reply_id: discussion_id, - }; - - if (isDiscussion && isInMRPage()) { - noteData.resolvable = note.resolvable; - noteData.resolved = false; - noteData.active = true; - noteData.resolve_path = note.resolve_path; - noteData.resolve_with_issue_path = note.resolve_with_issue_path; - noteData.diff_discussion = false; + let discussion = data.discussion || note.base_discussion; + + if (!discussion) { + discussion = { + expanded: true, + id: discussion_id, + individual_note: !isDiscussion, + reply_id: discussion_id, + }; + + if (isDiscussion && isInMRPage()) { + discussion.resolvable = note.resolvable; + discussion.resolved = false; + discussion.active = true; + discussion.resolve_path = note.resolve_path; + discussion.resolve_with_issue_path = note.resolve_with_issue_path; + discussion.diff_discussion = false; + } } - state.discussions.push(noteData); + note.base_discussion = undefined; // No point keeping a reference to this + discussion.notes = [note]; + + state.discussions.push(discussion); } }, |