2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2020-12-03 18:29:47 +01:00
|
|
|
import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings';
|
2020-06-12 22:44:25 +02:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
2020-12-03 18:29:47 +01:00
|
|
|
import { doSearch } from 'redux/actions/search';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import { doResolveUris, SETTINGS } from 'lbry-redux';
|
2019-02-05 19:36:40 +01:00
|
|
|
import analytics from 'analytics';
|
2017-12-21 22:08:54 +01:00
|
|
|
import Wunderbar from './view';
|
2017-05-04 05:44:08 +02:00
|
|
|
|
2020-12-03 18:29:47 +01:00
|
|
|
const select = (state, props) => ({
|
2020-11-20 14:21:31 +01:00
|
|
|
language: selectLanguage(state),
|
2020-12-03 18:29:47 +01:00
|
|
|
showMature: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
|
2019-03-28 17:53:13 +01:00
|
|
|
});
|
2017-05-04 05:44:08 +02:00
|
|
|
|
2019-04-04 23:05:23 +02:00
|
|
|
const perform = (dispatch, ownProps) => ({
|
2020-12-03 18:29:47 +01:00
|
|
|
doResolveUris: uris => dispatch(doResolveUris(uris)),
|
|
|
|
doSearch: (query, options) => dispatch(doSearch(query, options)),
|
|
|
|
navigateToSearchPage: query => {
|
2020-09-10 19:11:31 +02:00
|
|
|
let encodedQuery = encodeURIComponent(query);
|
|
|
|
ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodedQuery}` });
|
2019-02-05 19:36:40 +01:00
|
|
|
analytics.apiLogSearch();
|
2018-03-26 23:32:43 +02:00
|
|
|
},
|
2019-04-19 20:05:55 +02:00
|
|
|
doShowSnackBar: message => dispatch(doToast({ isError: true, message })),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-05-04 05:44:08 +02:00
|
|
|
|
2020-06-12 22:44:25 +02:00
|
|
|
export default withRouter(connect(select, perform)(Wunderbar));
|