From 8a918b9d9bc84d82eea94876268424375c99b45e Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Mon, 23 Jul 2018 09:40:06 +0200 Subject: Changelog + FIxes Tests + Optimises Getter --- .../diffs/components/parallel_diff_comment_row.vue | 8 +++++--- app/assets/javascripts/diffs/store/getters.js | 22 ++++++++++++---------- .../unreleased/tz-mr-refactor-memory-reduction.yml | 5 +++++ 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 changelogs/unreleased/tz-mr-refactor-memory-reduction.yml diff --git a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue index 0258ef5faa8..bb9a65c83fa 100644 --- a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue +++ b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue @@ -59,9 +59,11 @@ export default { shouldRenderDiscussionsOnRight() { return this.rightDiscussions && this.hasExpandedDiscussionOnRight && this.line.right.type; }, + showRightSideCommentForm() { + return this.line.right.type && this.diffLineCommentForms[this.rightLineCode]; + }, className() { - return (this.leftDiscussions && this.leftDiscussions.length > 0) || - (this.rightDiscussions && this.rightDiscussions.length > 0) + return this.leftDiscussions.length > 0 || this.rightDiscussions.length > 0 ? '' : 'js-temp-notes-holder'; }, @@ -105,7 +107,7 @@ export default { /> const isDiffDiscussion = note.diff_discussion; const hasLineCode = note.line_code; const isResolvable = note.resolvable; - const diffRefs = diffRefsByLineCode[note.line_code]; - if (isDiffDiscussion && hasLineCode && isResolvable && diffRefs) { - const refs = convertObjectPropsToCamelCase(note.position.formatter); - const originalRefs = convertObjectPropsToCamelCase(note.original_position.formatter); + if (isDiffDiscussion && hasLineCode && isResolvable) { + const diffRefs = diffRefsByLineCode[note.line_code]; + if (diffRefs) { + const refs = convertObjectPropsToCamelCase(note.position.formatter); + const originalRefs = convertObjectPropsToCamelCase(note.original_position.formatter); - if (_.isEqual(refs, diffRefs) || _.isEqual(originalRefs, diffRefs)) { - const lineCode = note.line_code; + if (_.isEqual(refs, diffRefs) || _.isEqual(originalRefs, diffRefs)) { + const lineCode = note.line_code; - if (acc[lineCode]) { - acc[lineCode].push(note); - } else { - acc[lineCode] = [note]; + if (acc[lineCode]) { + acc[lineCode].push(note); + } else { + acc[lineCode] = [note]; + } } } } diff --git a/changelogs/unreleased/tz-mr-refactor-memory-reduction.yml b/changelogs/unreleased/tz-mr-refactor-memory-reduction.yml new file mode 100644 index 00000000000..20b72c98bc1 --- /dev/null +++ b/changelogs/unreleased/tz-mr-refactor-memory-reduction.yml @@ -0,0 +1,5 @@ +--- +title: Reduces the client side memory footprint on merge requests +merge_request: 20744 +author: +type: performance -- cgit v1.2.1