Commit d8546930 authored by Thomas Randolph's avatar Thomas Randolph

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

parent 4f37e9d5
......@@ -283,10 +283,7 @@ export default {
},
created() {
this.adjustView();
notesEventHub.$once('fetchDiffData', this.fetchData);
notesEventHub.$on('refetchDiffData', this.refetchDiffData);
eventHub.$on(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
this.subscribeToEvents();
this.CENTERED_LIMITED_CONTAINER_CLASSES = CENTERED_LIMITED_CONTAINER_CLASSES;
......@@ -307,11 +304,7 @@ export default {
},
beforeDestroy() {
diffsApp.deinstrument();
eventHub.$off(EVT_VIEW_FILE_BY_FILE, this.fileByFileListener);
notesEventHub.$off('refetchDiffData', this.refetchDiffData);
notesEventHub.$off('fetchDiffData', this.fetchData);
this.unsubscribeFromEvents();
this.removeEventListeners();
},
methods: {
......@@ -331,6 +324,16 @@ export default {
'navigateToDiffFileIndex',
'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 } = {}) {
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