2020-03-27 13:59:38 -07:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:01:24 -08:00
|
|
|
import { getFeatures } from 'soapbox/utils/features';
|
2020-03-27 13:59:38 -07:00
|
|
|
import SearchResults from '../components/search_results';
|
|
|
|
import { fetchSuggestions, dismissSuggestion } from '../../../actions/suggestions';
|
2021-08-02 11:51:15 -07:00
|
|
|
import { expandSearch, setFilter } from '../../../actions/search';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2021-07-30 08:51:43 -07:00
|
|
|
const mapStateToProps = state => {
|
2021-10-15 09:07:47 -07:00
|
|
|
const instance = state.get('instance');
|
|
|
|
|
2021-07-30 08:51:43 -07:00
|
|
|
return {
|
2021-08-07 11:42:39 -07:00
|
|
|
value: state.getIn(['search', 'submittedValue']),
|
2021-07-30 08:51:43 -07:00
|
|
|
results: state.getIn(['search', 'results']),
|
|
|
|
suggestions: state.getIn(['suggestions', 'items']),
|
2021-11-01 18:37:39 -07:00
|
|
|
trends: state.getIn(['trends', 'items']),
|
2021-07-30 08:51:43 -07:00
|
|
|
submitted: state.getIn(['search', 'submitted']),
|
2021-08-02 11:51:15 -07:00
|
|
|
selectedFilter: state.getIn(['search', 'filter']),
|
2021-10-15 09:07:47 -07:00
|
|
|
features: getFeatures(instance),
|
2021-07-30 08:51:43 -07:00
|
|
|
};
|
|
|
|
};
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
fetchSuggestions: () => dispatch(fetchSuggestions()),
|
2021-07-30 08:51:43 -07:00
|
|
|
expandSearch: type => dispatch(expandSearch(type)),
|
2020-03-27 13:59:38 -07:00
|
|
|
dismissSuggestion: account => dispatch(dismissSuggestion(account.get('id'))),
|
2021-08-02 11:51:15 -07:00
|
|
|
selectFilter: newActiveFilter => dispatch(setFilter(newActiveFilter)),
|
2020-03-27 13:59:38 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SearchResults);
|