From b41cd8cb92d53454b2b160ba922d33801933a9cf Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 4 Dec 2019 18:08:46 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/assets/javascripts/diffs/components/app.vue | 31 ++++++++++++++++--------- app/assets/javascripts/diffs/store/actions.js | 2 +- app/assets/javascripts/diffs/store/mutations.js | 11 ++++++++- 3 files changed, 31 insertions(+), 13 deletions(-) (limited to 'app/assets/javascripts/diffs') diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 8039a9a7602..beda1a0dc14 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -144,6 +144,9 @@ export default { isLimitedContainer() { return !this.showTreeList && !this.isParallelView && !this.isFluidLayout; }, + shouldSetDiscussions() { + return this.isNotesFetched && !this.assignedDiscussions && !this.isLoading; + }, }, watch: { diffViewType() { @@ -160,6 +163,11 @@ export default { }, isLoading: 'adjustView', showTreeList: 'adjustView', + shouldSetDiscussions(newVal) { + if (newVal) { + this.setDiscussions(); + } + }, }, mounted() { this.setBaseConfig({ @@ -214,26 +222,28 @@ export default { isLatestVersion() { return window.location.search.indexOf('diff_id') === -1; }, + startDiffRendering() { + requestIdleCallback( + () => { + this.startRenderDiffsQueue(); + }, + { timeout: 1000 }, + ); + }, fetchData(toggleTree = true) { if (this.isLatestVersion() && this.glFeatures.diffsBatchLoad) { this.fetchDiffFilesMeta() .then(() => { if (toggleTree) this.hideTreeListIfJustOneFile(); + + this.startDiffRendering(); }) .catch(() => { createFlash(__('Something went wrong on our end. Please try again!')); }); this.fetchDiffFilesBatch() - .then(() => { - requestIdleCallback( - () => { - this.setDiscussions(); - this.startRenderDiffsQueue(); - }, - { timeout: 1000 }, - ); - }) + .then(() => this.startDiffRendering()) .catch(() => { createFlash(__('Something went wrong on our end. Please try again!')); }); @@ -246,7 +256,6 @@ export default { requestIdleCallback( () => { - this.setDiscussions(); this.startRenderDiffsQueue(); }, { timeout: 1000 }, @@ -262,7 +271,7 @@ export default { } }, setDiscussions() { - if (this.isNotesFetched && !this.assignedDiscussions && !this.isLoading) { + if (this.shouldSetDiscussions) { this.assignedDiscussions = true; requestIdleCallback( diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index d4594399ff5..5434184b450 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -119,7 +119,7 @@ export const fetchDiffFilesMeta = ({ commit, state }) => { .get(state.endpointMetadata) .then(({ data }) => { const strippedData = { ...data }; - strippedData.diff_files = []; + delete strippedData.diff_files; commit(types.SET_LOADING, false); commit(types.SET_MERGE_REQUEST_DIFFS, data.merge_request_diffs || []); commit(types.SET_DIFF_DATA, strippedData); diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index de2f68d729c..fccfd950d75 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -39,7 +39,16 @@ export default { }, [types.SET_DIFF_DATA](state, data) { - prepareDiffData(data); + if ( + !( + gon && + gon.features && + gon.features.diffsBatchLoad && + window.location.search.indexOf('diff_id') === -1 + ) + ) { + prepareDiffData(data); + } Object.assign(state, { ...convertObjectPropsToCamelCase(data), -- cgit v1.2.3