diff options
author | André Luís <aluis@gitlab.com> | 2018-07-31 03:50:31 +0300 |
---|---|---|
committer | André Luís <aluis@gitlab.com> | 2018-08-01 15:45:14 +0300 |
commit | 32737672fa0579dbf3e51fa6bbd0face3c8d6cc8 (patch) | |
tree | 4b69c69b702e339bf57aab7bebf11fa30d37f019 /app/assets/javascripts/notes/stores/mutations.js | |
parent | 02e35a0d2630d6995652d67d32fb2462ae2f68b2 (diff) |
Revert "Merge branch 'tz-mr-refactor-mem-posting' into 'master'"
This reverts commit 9c121352aa59098be357d82538a4878540a676c9, reversing
changes made to c1b335e0122052ff51e9c55f150f13e841737797.
Diffstat (limited to 'app/assets/javascripts/notes/stores/mutations.js')
-rw-r--r-- | app/assets/javascripts/notes/stores/mutations.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index e1b159142c9..ab6a95e2601 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -174,19 +174,27 @@ export default { [types.UPDATE_NOTE](state, note) { const noteObj = utils.findNoteObjectById(state.discussions, note.discussion_id); + if (noteObj.individual_note) { noteObj.notes.splice(0, 1, note); } else { const comment = utils.findNoteObjectById(noteObj.notes, note.id); - Object.assign(comment, note); + noteObj.notes.splice(noteObj.notes.indexOf(comment), 1, note); } }, [types.UPDATE_DISCUSSION](state, noteData) { const note = noteData; - const selectedDiscussion = state.discussions.find(n => n.id === note.id); + let index = 0; + + state.discussions.forEach((n, i) => { + if (n.id === note.id) { + index = i; + } + }); + note.expanded = true; // override expand flag to prevent collapse - Object.assign(selectedDiscussion, note); + state.discussions.splice(index, 1, note); }, [types.CLOSE_ISSUE](state) { @@ -207,9 +215,12 @@ export default { [types.SET_DISCUSSION_DIFF_LINES](state, { discussionId, diffLines }) { const discussion = utils.findNoteObjectById(state.discussions, discussionId); + const index = state.discussions.indexOf(discussion); - Object.assign(discussion, { + const discussionWithDiffLines = Object.assign({}, discussion, { truncated_diff_lines: diffLines, }); + + state.discussions.splice(index, 1, discussionWithDiffLines); }, }; |