diff --git a/client/coral-admin/src/actions/assets.js b/client/coral-admin/src/actions/assets.js index b13454a21..df2e1bd60 100644 --- a/client/coral-admin/src/actions/assets.js +++ b/client/coral-admin/src/actions/assets.js @@ -8,6 +8,6 @@ export const updateAssetState = (id, closedAt) => (dispatch) => { dispatch({type: UPDATE_ASSET_STATE, id, closedAt}); }; -export const fetchAssets = (skip, limit, search, sort) => (dispatch) => { - dispatch({type: FETCH_ASSETS, skip, limit, search, sort}); +export const fetchAssets = (skip, limit, search, sort, filter) => (dispatch) => { + dispatch({type: FETCH_ASSETS, skip, limit, search, sort, filter}); }; diff --git a/client/coral-admin/src/containers/Streams/Streams.js b/client/coral-admin/src/containers/Streams/Streams.js index 5d8508f33..58c1c9b61 100644 --- a/client/coral-admin/src/containers/Streams/Streams.js +++ b/client/coral-admin/src/containers/Streams/Streams.js @@ -19,8 +19,9 @@ class Streams extends Component { state = { search: '', sort: 'desc', - statusFilter: 'all', - statusMenus: {} + filter: 'all', + statusMenus: {}, + timer: null } componentDidMount () { @@ -28,8 +29,22 @@ class Streams extends Component { } onSettingChange = (setting) => (e) => { + let options = this.state; this.setState({[setting]: e.target.value}); - this.props.fetchAssets(0, limit, this.state.search, this.state.sort); + options[setting] = e.target.value; + this.props.fetchAssets(0, limit, options.search, options.sort, options.filter); + } + + onSearchChange = (e) => { + this.setState({search: e.target.value}); + this.setState((prevState) => { + clearTimeout(prevState.timer); + const fetchAssets = this.props.fetchAssets; + prevState.timer = setTimeout(() => { + fetchAssets(0, limit, this.state.search, this.state.sort, this.state.filter); + }, 350); + return prevState; + }); } renderDate = (date) => { @@ -74,7 +89,7 @@ class Streams extends Component { } render () { - const {searchTerm, sortBy, statusFilter} = this.state; + const {search, sort, filter} = this.state; const {assets} = this.props; return