Skip to content

Commit

Permalink
Ensure we use the stream filter when is mounted (#3390)
Browse files Browse the repository at this point in the history
As the component mounted state is a bit tricky, check if we need to
filter the list of streams after each update. Also ensure that the
reference is available at the time.

Fixes #3389
  • Loading branch information
edmundoa authored and joschi committed Jan 19, 2017
1 parent 30f8d81 commit ce2adf1
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -30,6 +30,13 @@ const StreamComponent = React.createClass({
StreamsStore.onChange(this.loadData);
StreamRulesStore.onChange(this.loadData);
},

componentDidUpdate() {
if (this.state.filteredStreams === null) {
this._filterStreams();
}
},

componentWillUnmount() {
StreamsStore.unregister(this.loadData);
StreamRulesStore.unregister(this.loadData);
Expand All @@ -41,10 +48,15 @@ const StreamComponent = React.createClass({
streams: streams,
filteredStreams: null,
});
this.refs.streamFilter.filterData();
});
},

_filterStreams() {
if (this.refs.streamFilter) {
this.refs.streamFilter.filterData();
}
},

_updateFilteredStreams(filteredStreams) {
this.setState({filteredStreams: filteredStreams});
},
Expand Down

0 comments on commit ce2adf1

Please sign in to comment.