lbry-desktop/ui/component/wunderbar/index.js

27 lines
1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2020-12-03 18:29:47 +01:00
import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings';
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';
import Wunderbar from './view';
2017-05-04 05:44:08 +02:00
2020-12-03 18:29:47 +01:00
const select = (state, props) => ({
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 => {
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
},
doShowSnackBar: message => dispatch(doToast({ isError: true, message })),
2017-06-06 06:21:55 +02:00
});
2017-05-04 05:44:08 +02:00
export default withRouter(connect(select, perform)(Wunderbar));