Fixes diff discussions not being fully removed

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
This commit is contained in:
Phil Hughes 2018-10-30 10:41:25 +00:00
parent 6d7e52bdeb
commit 605e7fddc8
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F
3 changed files with 5 additions and 8 deletions

View file

@ -153,13 +153,9 @@ export default {
},
setDiscussions() {
if (this.isNotesFetched && !this.assignedDiscussions && !this.isLoading) {
requestIdleCallback(
() =>
this.assignDiscussionsToDiff().then(() => {
this.assignedDiscussions = true;
}),
{ timeout: 1000 },
);
requestIdleCallback(() => this.assignDiscussionsToDiff(), { timeout: 1000 });
}
},
adjustView() {

View file

@ -133,7 +133,7 @@ export default {
},
right: {
...line.right,
discussions: right ? line.right.discussions.concat(discussion) : [],
discussions: right && !left ? line.right.discussions.concat(discussion) : [],
},
};
}

View file

@ -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);