Skip to content

Commit

Permalink
Fix duplicate fetch in Visualize
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Jul 29, 2019
1 parent bf032e9 commit 11480fb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function VisEditor(
const filterUpdateSubscription = subscribeWithScope($scope, queryFilter.getUpdates$(), {
next: () => {
$scope.filters = queryFilter.getFilters();
$scope.fetch();
$scope.globalFilters = queryFilter.getGlobalFilters();
}
});

Expand All @@ -415,7 +415,6 @@ function VisEditor(
$state.save();
savedVis.searchSource.setField('query', $state.query);
savedVis.searchSource.setField('filter', $state.filters);
$scope.globalFilters = queryFilter.getGlobalFilters();
$scope.vis.forceReload();
};

Expand All @@ -441,9 +440,16 @@ function VisEditor(
}

$scope.updateQueryAndFetch = function ({ query, dateRange }) {
timefilter.setTime(dateRange);
$state.query = query;
$scope.fetch();
const isUpdate = (
(query && !_.isEqual(query, $state.query)) ||
(dateRange && !_.isEqual(dateRange, $scope.timeRange))
);

if (query && !_.isEqual(query, $state.query)) $state.query = query;
if (dateRange && !_.isEqual(dateRange, $scope.timeRange)) timefilter.setTime(dateRange);

// If nothing has changed, trigger the fetch manually, otherwise it will happen as a result of the changes
if (!isUpdate) $scope.fetch();
};

$scope.onRefreshChange = function ({ isPaused, refreshInterval }) {
Expand Down

0 comments on commit 11480fb

Please sign in to comment.