Skip to content

Commit

Permalink
add autoRefreshFetch event to timefilter (#20863) (#21148)
Browse files Browse the repository at this point in the history
* add autoRefreshFetch event to timefilter

* replace fetchAndRender with reloadVis remove listener from editor

* unsubscribe correct handler
  • Loading branch information
nreese authored and timroes committed Jul 24, 2018
1 parent 59b8c8e commit 2170ab0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ui/public/courier/search_poll/search_poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { fatalError } from '../../notify';
import '../../promises';
import { searchRequestQueue } from '../search_request_queue';
import { FetchSoonProvider } from '../fetch';
import { timefilter } from 'ui/timefilter';

export function SearchPollProvider(Private, Promise) {
const fetchSoon = Private(FetchSoonProvider);
Expand Down Expand Up @@ -81,6 +82,7 @@ export function SearchPollProvider(Private, Promise) {
// We use resolve() here instead of try() because the latter won't trigger a $digest
// when the promise resolves.
this._searchPromise = Promise.resolve().then(() => {
timefilter.emit('autoRefreshFetch');
const requests = searchRequestQueue.getInactive();

// The promise returned from fetchSearchRequests() only resolves when the requests complete.
Expand Down
3 changes: 3 additions & 0 deletions src/ui/public/visualize/loader/embedded_visualize_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { EventEmitter } from 'events';
import { visualizationLoader } from './visualization_loader';
import { VisualizeDataLoader } from './visualize_data_loader';
import { RenderCompleteHelper } from '../../render_complete';
import { timefilter } from 'ui/timefilter';

const RENDER_COMPLETE_EVENT = 'render_complete';

Expand Down Expand Up @@ -71,6 +72,7 @@ export class EmbeddedVisualizeHandler {
this._vis.on('update', this._handleVisUpdate);
this._vis.on('reload', this._reloadVis);
this._uiState.on('change', this._fetchAndRender);
timefilter.on('autoRefreshFetch', this._reloadVis);

this._visualize = new VisualizeDataLoader(this._vis, Private);
this._renderCompleteHelper = new RenderCompleteHelper(this._element);
Expand Down Expand Up @@ -168,6 +170,7 @@ export class EmbeddedVisualizeHandler {
destroy() {
this._destroyed = true;
this._fetchAndRender.cancel();
timefilter.off('autoRefreshFetch', this._reloadVis);
this._vis.removeListener('reload', this._reloadVis);
this._vis.removeListener('update', this._handleVisUpdate);
this._element.removeEventListener('renderComplete', this._elementListener);
Expand Down

0 comments on commit 2170ab0

Please sign in to comment.