Skip to content
Snippets Groups Projects
Commit e70d06df authored by Tim Zallmann's avatar Tim Zallmann
Browse files

Incremental Rendering of the MR

parent f68f405c
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -114,11 +114,16 @@ export default {
this.adjustView();
},
methods: {
...mapActions('diffs', ['setBaseConfig', 'fetchDiffFiles']),
...mapActions('diffs', ['setBaseConfig', 'fetchDiffFiles', 'startRenderDiffsQueue']),
fetchData() {
this.fetchDiffFiles().catch(() => {
createFlash(__('Something went wrong on our end. Please try again!'));
});
this.fetchDiffFiles()
.then(() => {
console.log('Done');
requestIdleCallback(this.startRenderDiffsQueue, { timeout: 1000 });
})
.catch(() => {
createFlash(__('Something went wrong on our end. Please try again!'));
});
 
if (!this.isNotesFetched) {
eventHub.$emit('fetchNotesData');
Loading
Loading
Loading
Loading
@@ -121,12 +121,12 @@ export default {
</div>
 
<diff-content
v-if="!isCollapsed"
v-if="!isCollapsed && file.renderIt"
:class="{ hidden: isCollapsed || file.tooLarge }"
:diff-file="file"
/>
<loading-icon
v-if="isLoadingCollapsedDiff"
v-if="isLoadingCollapsedDiff || !file.renderIt"
class="diff-content loading"
/>
<div
Loading
Loading
Loading
Loading
@@ -29,6 +29,26 @@ export const fetchDiffFiles = ({ state, commit }) => {
.then(handleLocationHash);
};
 
export const startRenderDiffsQueue = ({ state, commit }) => {
const checkItem = () => {
const nextFile = state.diffFiles.find(file => !file.renderIt && !file.collapsed);
if (nextFile) {
requestAnimationFrame(() => {
commit(types.RENDER_FILE, nextFile);
});
requestIdleCallback(
() => {
console.log('CALL NEXT');
checkItem();
},
{ timeout: 1000 },
);
}
};
checkItem();
};
export const setInlineDiffViewType = ({ commit }) => {
commit(types.SET_DIFF_VIEW_TYPE, INLINE_DIFF_VIEW_TYPE);
 
Loading
Loading
Loading
Loading
@@ -8,3 +8,4 @@ export const REMOVE_COMMENT_FORM_LINE = 'REMOVE_COMMENT_FORM_LINE';
export const ADD_CONTEXT_LINES = 'ADD_CONTEXT_LINES';
export const ADD_COLLAPSED_DIFFS = 'ADD_COLLAPSED_DIFFS';
export const EXPAND_ALL_FILES = 'EXPAND_ALL_FILES';
export const RENDER_FILE = 'RENDER_FILE';
Loading
Loading
@@ -15,8 +15,26 @@ export default {
},
 
[types.SET_DIFF_DATA](state, data) {
const diffData = convertObjectPropsToCamelCase(data, { deep: true });
let showingLines = 0;
diffData.diffFiles.map(file => {
if (file.highlightedDiffLines) {
showingLines += file.parallelDiffLines.length;
Object.assign(file, {
renderIt: showingLines < 200,
collapsed: showingLines > 2000,
});
}
});
Object.assign(state, {
...convertObjectPropsToCamelCase(data, { deep: true }),
...diffData,
});
},
[types.RENDER_FILE](state, file) {
Object.assign(file, {
renderIt: true,
});
},
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment