Stop listening to filter updates when exiting Visualize (#14647)

This commit is contained in:
Thomas Neirynck 2017-10-31 15:42:03 -04:00 committed by GitHub
parent 32a74e1ad1
commit a348ea74e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,14 +121,17 @@ uiModules
});
}, 100);
$scope.vis.on('update', () => {
//todo: clean this one up as well
const handleVisUpdate = () => {
if ($scope.editorMode) {
$scope.appState.vis = $scope.vis.getState();
$scope.appState.save();
} else {
$scope.fetch();
}
});
};
$scope.vis.on('update', handleVisUpdate);
const reload = () => {
$scope.vis.reload = true;
@ -139,7 +142,13 @@ uiModules
$scope.$on('courier:searchRefresh', reload);
// dashboard will fire fetch event when it wants to refresh
$scope.$on('fetch', reload);
queryFilter.on('update', $scope.fetch);
const handleQueryUpdate = ()=> {
$scope.fetch();
};
queryFilter.on('update', handleQueryUpdate);
if ($scope.appState) {
let oldUiState;
@ -187,6 +196,8 @@ uiModules
});
$scope.$on('$destroy', () => {
$scope.vis.removeListener('update', handleVisUpdate);
queryFilter.off('update', handleQueryUpdate);
resizeChecker.destroy();
});