summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/components/parallel_diff_view.vue
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2018-07-23 11:24:07 +0000
committerFatih Acet <acetfatih@gmail.com>2018-07-23 11:24:07 +0000
commitb2dbc93694cfd8c7d83c77327096651b5a40d77a (patch)
tree802d86555bdd146457714778d3af01e3fcbe3ef4 /app/assets/javascripts/diffs/components/parallel_diff_view.vue
parent58a0df7e68e46902e453a0252e6753517d9cf665 (diff)
downloadgitlab-ce-b2dbc93694cfd8c7d83c77327096651b5a40d77a.tar.gz
Reducing the memory footprint for the rendering
Diffstat (limited to 'app/assets/javascripts/diffs/components/parallel_diff_view.vue')
-rw-r--r--app/assets/javascripts/diffs/components/parallel_diff_view.vue38
1 files changed, 10 insertions, 28 deletions
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_view.vue b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
index 8f8d6bbc818..4d97cb6d15d 100644
--- a/app/assets/javascripts/diffs/components/parallel_diff_view.vue
+++ b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
@@ -21,7 +21,11 @@ export default {
},
},
computed: {
- ...mapGetters('diffs', ['commitId', 'discussionsByLineCode']),
+ ...mapGetters('diffs', [
+ 'commitId',
+ 'singleDiscussionByLineCode',
+ 'shouldRenderParallelCommentRow',
+ ]),
...mapState({
diffLineCommentForms: state => state.diffs.diffLineCommentForms,
}),
@@ -51,32 +55,6 @@ export default {
return window.gon.user_color_scheme;
},
},
- methods: {
- shouldRenderCommentRow(line) {
- const leftLineCode = line.left.lineCode;
- const rightLineCode = line.right.lineCode;
- const discussions = this.discussionsByLineCode;
- const leftDiscussions = discussions[leftLineCode];
- const rightDiscussions = discussions[rightLineCode];
- const hasDiscussion = leftDiscussions || rightDiscussions;
-
- const hasExpandedDiscussionOnLeft = leftDiscussions
- ? leftDiscussions.every(discussion => discussion.expanded)
- : false;
- const hasExpandedDiscussionOnRight = rightDiscussions
- ? rightDiscussions.every(discussion => discussion.expanded)
- : false;
-
- if (hasDiscussion && (hasExpandedDiscussionOnLeft || hasExpandedDiscussionOnRight)) {
- return true;
- }
-
- const hasCommentFormOnLeft = this.diffLineCommentForms[leftLineCode];
- const hasCommentFormOnRight = this.diffLineCommentForms[rightLineCode];
-
- return hasCommentFormOnLeft || hasCommentFormOnRight;
- },
- },
};
</script>
@@ -97,13 +75,17 @@ export default {
:line="line"
:is-bottom="index + 1 === diffLinesLength"
:key="index"
+ :left-discussions="singleDiscussionByLineCode(line.left.lineCode)"
+ :right-discussions="singleDiscussionByLineCode(line.right.lineCode)"
/>
<parallel-diff-comment-row
- v-if="shouldRenderCommentRow(line)"
+ v-if="shouldRenderParallelCommentRow(line)"
:key="`dcr-${index}`"
:line="line"
:diff-file-hash="diffFile.fileHash"
:line-index="index"
+ :left-discussions="singleDiscussionByLineCode(line.left.lineCode)"
+ :right-discussions="singleDiscussionByLineCode(line.right.lineCode)"
/>
</template>
</tbody>