Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Jan 22, 2020
1 parent 7189cf6 commit 4ad51c3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/plugins/data/public/query/filter_manager/filter_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,23 @@ export class FilterManager {
const appFilters = partitionedFilters.appFilters;

// existing globalFilters should be mutated by appFilters
// ignore original appFilters which are already inside globalFilters
const cleanedAppFilters: esFilters.Filter[] = [];
_.each(appFilters, function(filter, i) {
const match = _.find(globalFilters, function(globalFilter) {
return compareFilters(globalFilter, filter);
});

// no match, do nothing
if (!match) return;
// no match, do continue with app filter
if (!match) {
return cleanedAppFilters.push(filter);
}

// matching filter in globalState, update global and remove from appState
// matching filter in globalState, update global and don't add from appState
_.assign(match.meta, filter.meta);
appFilters.splice(i, 1);
});

return FilterManager.mergeFilters(appFilters, globalFilters);
return FilterManager.mergeFilters(cleanedAppFilters, globalFilters);
}

private static mergeFilters(
Expand Down

0 comments on commit 4ad51c3

Please sign in to comment.