Commit 89fb8f24 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'maintenance/clean-up-diffs-events' into 'master'

Centralize how the Diffs app attaches/detaches from the event hub

See merge request gitlab-org/gitlab!49173
parents b94daeb4 d8546930
...@@ -283,10 +283,7 @@ export default { ...@@ -283,10 +283,7 @@ export default {
}, },
created() { created() {
this.adjustView(); this.adjustView();
this.subscribeToEvents();
notesEventHub.$once('fetchDiffData', this.fetchData);
notesEventHub.$on('refetchDiffData', this.refetchDiffData);
eventHub.$on(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES; this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES;
...@@ -307,11 +304,7 @@ export default { ...@@ -307,11 +304,7 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
diffsApp.deinstrument(); diffsApp.deinstrument();
this.unsubscribeFromEvents();
eventHub.$off(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
notesEventHub.$off('refetchDiffData', this.refetchDiffData);
notesEventHub.$off('fetchDiffData', this.fetchData);
this.removeEventListeners(); this.removeEventListeners();
}, },
methods: { methods: {
...@@ -331,6 +324,16 @@ export default { ...@@ -331,6 +324,16 @@ export default {
'navigateToDiffFileIndex', 'navigateToDiffFileIndex',
'setFileByFile', 'setFileByFile',
]), ]),
subscribeToEvents() {
notesEventHub.$once('fetchDiffData', this.fetchData);
notesEventHub.$on('refetchDiffData', this.refetchDiffData);
eventHub.$on(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
},
unsubscribeFromEvents() {
eventHub.$off(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
notesEventHub.$off('refetchDiffData', this.refetchDiffData);
notesEventHub.$off('fetchDiffData', this.fetchData);
},
fileByFileListener({ setting } = {}) { fileByFileListener({ setting } = {}) {
this.setFileByFile({ fileByFile: setting }); this.setFileByFile({ fileByFile: setting });
}, },
......
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