Skip to content

Commit

Permalink
made controls re-initialize when useTimeFilter is true, and the filte…
Browse files Browse the repository at this point in the history
…r changes
  • Loading branch information
ThomThomson committed Sep 3, 2020
1 parent 4fb0935 commit 49b807b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/input_control_vis/public/vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React from 'react';
import { isEqual } from 'lodash';
import { render, unmountComponentAtNode } from 'react-dom';

import { merge, Subscription } from 'rxjs';
import { I18nStart } from 'kibana/public';
import { InputControlVis } from './components/vis/input_control_vis';
import { getControlFactory } from './control/control_factory';
Expand All @@ -41,6 +42,7 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
queryBarUpdateHandler: () => void;
filterManager: FilterManager;
updateSubsciption: any;
timeFilterSubscription: Subscription;
visParams?: VisParams;

constructor(public el: Element, public vis: Vis) {
Expand All @@ -52,6 +54,13 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
this.updateSubsciption = this.filterManager
.getUpdates$()
.subscribe(this.queryBarUpdateHandler);
this.timeFilterSubscription = deps.data.query.timefilter.timefilter
.getTimeUpdate$()
.subscribe(() => {
if (this.visParams?.useTimeFilter) {
this.isLoaded = false;
}
});
}

async render(visData: any, visParams: VisParams) {
Expand All @@ -68,6 +77,7 @@ export const createInputControlVisController = (deps: InputControlVisDependencie

destroy() {
this.updateSubsciption.unsubscribe();
this.timeFilterSubscription.unsubscribe();
unmountComponentAtNode(this.el);
this.controls.forEach((control) => control.destroy());
}
Expand Down

0 comments on commit 49b807b

Please sign in to comment.