diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-07-04 02:18:27 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-07-04 02:18:27 +0300 |
commit | 483864db77acb6db479ecdb8ce4dd121731a8330 (patch) | |
tree | 68fad0ba107207a5df667805bbe1af4990b50175 /app/assets/javascripts/diffs/components/parallel_diff_view.vue | |
parent | 26998c68c936f183ead1a84e404a61160fc646f7 (diff) |
Improve performance of toggling diff view type
Diffstat (limited to 'app/assets/javascripts/diffs/components/parallel_diff_view.vue')
-rw-r--r-- | app/assets/javascripts/diffs/components/parallel_diff_view.vue | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_view.vue b/app/assets/javascripts/diffs/components/parallel_diff_view.vue index ed92b4ee249..d7280338b68 100644 --- a/app/assets/javascripts/diffs/components/parallel_diff_view.vue +++ b/app/assets/javascripts/diffs/components/parallel_diff_view.vue @@ -1,25 +1,53 @@ <script> -import diffContentMixin from '../mixins/diff_content'; +import { mapGetters } from 'vuex'; +import parallelDiffTableRow from './parallel_diff_table_row.vue'; import parallelDiffCommentRow from './parallel_diff_comment_row.vue'; import { EMPTY_CELL_TYPE } from '../constants'; +import { trimFirstCharOfLineContent } from '../store/utils'; export default { components: { + parallelDiffTableRow, parallelDiffCommentRow, }, - mixins: [diffContentMixin], + props: { + diffFile: { + type: Object, + required: true, + }, + diffLines: { + type: Array, + required: true, + }, + }, computed: { + ...mapGetters(['commit']), parallelDiffLines() { - return this.normalizedDiffLines.map(line => { - if (!line.left) { + return this.diffLines.map(line => { + if (line.left) { + Object.assign(line, { left: trimFirstCharOfLineContent(line.left) }); + } else { Object.assign(line, { left: { type: EMPTY_CELL_TYPE } }); - } else if (!line.right) { + } + + if (line.right) { + Object.assign(line, { right: trimFirstCharOfLineContent(line.right) }); + } else { Object.assign(line, { right: { type: EMPTY_CELL_TYPE } }); } return line; }); }, + diffLinesLength() { + return this.parallelDiffLines.length; + }, + commitId() { + return this.commit && this.commit.id; + }, + userColorScheme() { + return window.gon.user_color_scheme; + }, }, }; </script> @@ -35,7 +63,7 @@ export default { <template v-for="(line, index) in parallelDiffLines" > - <diff-table-row + <parallel-diff-table-row :diff-file="diffFile" :line="line" :is-bottom="index + 1 === diffLinesLength" |