summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-10-30 10:41:25 +0000
committerPhil Hughes <me@iamphill.com>2018-10-30 10:41:25 +0000
commit605e7fddc8f399e6d4cc8ceecb60d9c818b25a7f (patch)
tree69b12d173ea4d257f29be3af68b1497250612d5d
parent6d7e52bdeb062d0f4af46f3c5756841db5a67a5f (diff)
downloadgitlab-ce-605e7fddc8f399e6d4cc8ceecb60d9c818b25a7f.tar.gz
Fixes diff discussions not being fully removedmr-diff-discussion-deletion
This fixes a bug where a discussion on a none changed line would not get fully removed and therefore leave the comment row empty. This was caused by the discussiob being added to the right when it shouldnt of been This also fixes a very rare edge case where discussions would get added twice to diff lines causing a Vue rendering warning Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53317
-rw-r--r--app/assets/javascripts/diffs/components/app.vue10
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js2
-rw-r--r--spec/javascripts/diffs/store/mutations_spec.js1
3 files changed, 5 insertions, 8 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue
index a8d615dd8f0..59680959bb1 100644
--- a/app/assets/javascripts/diffs/components/app.vue
+++ b/app/assets/javascripts/diffs/components/app.vue
@@ -153,13 +153,9 @@ export default {
},
setDiscussions() {
if (this.isNotesFetched && !this.assignedDiscussions && !this.isLoading) {
- requestIdleCallback(
- () =>
- this.assignDiscussionsToDiff().then(() => {
- this.assignedDiscussions = true;
- }),
- { timeout: 1000 },
- );
+ this.assignedDiscussions = true;
+
+ requestIdleCallback(() => this.assignDiscussionsToDiff(), { timeout: 1000 });
}
},
adjustView() {
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index 5a8aebd2086..38a65f111a2 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -133,7 +133,7 @@ export default {
},
right: {
...line.right,
- discussions: right ? line.right.discussions.concat(discussion) : [],
+ discussions: right && !left ? line.right.discussions.concat(discussion) : [],
},
};
}
diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js
index 4b6d3d5bcba..fed04cbaed8 100644
--- a/spec/javascripts/diffs/store/mutations_spec.js
+++ b/spec/javascripts/diffs/store/mutations_spec.js
@@ -221,6 +221,7 @@ describe('DiffsStoreMutations', () => {
expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).toEqual(1);
expect(state.diffFiles[0].parallelDiffLines[0].left.discussions[0].id).toEqual(1);
+ expect(state.diffFiles[0].parallelDiffLines[0].right.discussions).toEqual([]);
expect(state.diffFiles[0].highlightedDiffLines[0].discussions.length).toEqual(1);
expect(state.diffFiles[0].highlightedDiffLines[0].discussions[0].id).toEqual(1);