Skip to content

Commit

Permalink
Fix infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Feb 6, 2020
2 parents 4880d6b + 4fff8e8 commit 71144c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 0 additions & 3 deletions x-pack/legacy/plugins/lens/public/app_plugin/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,11 @@ describe('Lens App', () => {
it('loads a document and uses query and filters if there is a document id', async () => {
const args = makeDefaultArgs();
args.editorFrame = frame;

const savedFilter = {
query: { match_phrase: { src: 'test' } },
$state: { store: esFilters.FilterStateStore.APP_STATE },
meta: { disabled: false, negate: false, alias: null },
};

(args.docStorage.load as jest.Mock).mockResolvedValue({
id: '1234',
expression: 'valid expression',
Expand Down Expand Up @@ -770,7 +768,6 @@ describe('Lens App', () => {
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;

await waitForPromises();
const filter = {
...esFilters.buildExistsFilter(field, indexPattern),
$state: { store: esFilters.FilterStateStore.APP_STATE },
Expand Down
7 changes: 2 additions & 5 deletions x-pack/legacy/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,16 @@ export function App({
fromDate: currentRange.from,
toDate: currentRange.to,
},
filters: data.query.filterManager.getFilters(),
};
});

const { lastKnownDoc } = state;

useEffect(() => {
// Clear app-specific filters when navigating to Lens. Necessary because Lens
// can be loaded without a full page refresh, using the same singleton
if (data.query.filterManager.getAppFilters().length) {
if (data.query.filterManager.getAppFilters().length > 0) {
data.query.filterManager.setFilters(data.query.filterManager.getGlobalFilters());
}

const filterSubscription = data.query.filterManager.getUpdates$().subscribe({
next: () => {
// Trigger a re-render, since filters are no longer tracked on state
Expand Down Expand Up @@ -128,7 +126,6 @@ export function App({
core.notifications
)
.then(indexPatterns => {
// Keep any pinned filters and set app filters from doc
data.query.filterManager.setFilters(
data.query.filterManager
.getGlobalFilters()
Expand Down

0 comments on commit 71144c6

Please sign in to comment.