Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-06-29 10:22:07 +0300
committerTim Zallmann <tzallmann@gitlab.com>2018-06-29 10:22:07 +0300
commitd690cd9992dbd6a0d231f6c7ea1688ef90f9fc2e (patch)
tree02df5a6d7e6711612180cb155dfad0944a7454ca /app/assets/javascripts/diffs/components/app.vue
parent7c6d7accff0a4921d3c863a38382a6114ddb825e (diff)
Prevent fetching diffs and discussions data unnecessarily on MR page
Diffstat (limited to 'app/assets/javascripts/diffs/components/app.vue')
-rw-r--r--app/assets/javascripts/diffs/components/app.vue25
1 files changed, 21 insertions, 4 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue
index deddb61ca31..e0aecda54f6 100644
--- a/app/assets/javascripts/diffs/components/app.vue
+++ b/app/assets/javascripts/diffs/components/app.vue
@@ -3,6 +3,7 @@ import { mapState, mapGetters, mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale';
import createFlash from '~/flash';
+import eventHub from '../../notes/event_hub';
import LoadingIcon from '../../vue_shared/components/loading_icon.vue';
import CompareVersions from './compare_versions.vue';
import ChangedFiles from './changed_files.vue';
@@ -62,7 +63,7 @@ export default {
plainDiffPath: state => state.diffs.plainDiffPath,
emailPatchPath: state => state.diffs.emailPatchPath,
}),
- ...mapGetters(['isParallelView']),
+ ...mapGetters(['isParallelView', 'isNotesFetched']),
targetBranch() {
return {
branchName: this.targetBranchName,
@@ -94,20 +95,36 @@ export default {
this.adjustView();
},
shouldShow() {
+ // When the shouldShow property changed to true, the route is rendered for the first time
+ // and if we have the isLoading as true this means we didn't fetch the data
+ if (this.isLoading) {
+ this.fetchData();
+ }
+
this.adjustView();
},
},
mounted() {
this.setBaseConfig({ endpoint: this.endpoint, projectPath: this.projectPath });
- this.fetchDiffFiles().catch(() => {
- createFlash(__('Fetching diff files failed. Please reload the page to try again!'));
- });
+
+ if (this.shouldShow) {
+ this.fetchData();
+ }
},
created() {
this.adjustView();
},
methods: {
...mapActions(['setBaseConfig', 'fetchDiffFiles']),
+ fetchData() {
+ this.fetchDiffFiles().catch(() => {
+ createFlash(__('Something went wrong on our end. Please try again!'));
+ });
+
+ if (!this.isNotesFetched) {
+ eventHub.$emit('fetchNotesData');
+ }
+ },
setActive(filePath) {
this.activeFile = filePath;
},