Commit 6f46b274 authored by Tim Zallmann's avatar Tim Zallmann

Updated discussion loading to be deferred and in the state

parent 95c8e747
...@@ -112,7 +112,6 @@ export default { ...@@ -112,7 +112,6 @@ export default {
}, },
created() { created() {
this.adjustView(); this.adjustView();
eventHub.$once('renderedFiles', this.assignDiscussionsToDiff);
}, },
methods: { methods: {
...mapActions('diffs', [ ...mapActions('diffs', [
...@@ -130,7 +129,12 @@ export default { ...@@ -130,7 +129,12 @@ export default {
this.startRenderDiffsQueue() this.startRenderDiffsQueue()
.then(() => { .then(() => {
console.log('Done rendering Que'); console.log('Done rendering Que');
requestIdleCallback(
() => {
this.assignDiscussionsToDiff(this.discussionsStructuredByLineCode); this.assignDiscussionsToDiff(this.discussionsStructuredByLineCode);
},
{ timeout: 1000 },
);
}) })
.catch(() => { .catch(() => {
createFlash(__('Something went wrong on our end. Please try again!')); createFlash(__('Something went wrong on our end. Please try again!'));
......
...@@ -24,13 +24,18 @@ export default { ...@@ -24,13 +24,18 @@ export default {
let i; let i;
for (i = 0; i < filesLength; i += 1) { for (i = 0; i < filesLength; i += 1) {
const file = diffData.diffFiles[i]; const file = diffData.diffFiles[i];
if (file.parallelDiffLines) { if (file.parallelDiffLines) {
const linesLength = file.parallelDiffLines.length; const linesLength = file.parallelDiffLines.length;
let u = 0; let u = 0;
for (u = 0; u < linesLength; u += 1) { for (u = 0; u < linesLength; u += 1) {
const line = file.parallelDiffLines[u]; const line = file.parallelDiffLines[u];
if (line.left) delete line.left.text; if (line.left) {
if (line.right) delete line.right.text; line.left = trimFirstCharOfLineContent(line.left);
}
if (line.right) {
line.right = trimFirstCharOfLineContent(line.right);
}
} }
} }
...@@ -38,14 +43,11 @@ export default { ...@@ -38,14 +43,11 @@ export default {
const linesLength = file.highlightedDiffLines.length; const linesLength = file.highlightedDiffLines.length;
let u; let u;
for (u = 0; u < linesLength; u += 1) { for (u = 0; u < linesLength; u += 1) {
const line = file.highlightedDiffLines[u]; trimFirstCharOfLineContent(file.highlightedDiffLines[u]);
delete line.text;
}
} }
if (file.highlightedDiffLines) {
showingLines += file.parallelDiffLines.length; showingLines += file.parallelDiffLines.length;
} }
Object.assign(file, { Object.assign(file, {
renderIt: showingLines < LINES_TO_BE_RENDERED_DIRECTLY, renderIt: showingLines < LINES_TO_BE_RENDERED_DIRECTLY,
collapsed: file.text && showingLines > MAX_LINES_TO_BE_RENDERED, collapsed: file.text && showingLines > MAX_LINES_TO_BE_RENDERED,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment