2020-12-11 19:33:27 +01:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
|
|
|
import { connect } from 'react-redux';
|
2021-03-31 21:07:11 +02:00
|
|
|
import { selectLanguage, selectShowMatureContent } from 'redux/selectors/settings';
|
2020-12-11 19:33:27 +01:00
|
|
|
import { doToast } from 'redux/actions/notifications';
|
|
|
|
import { doSearch } from 'redux/actions/search';
|
2020-12-30 23:16:06 +01:00
|
|
|
import { doOpenModal, doHideModal } from 'redux/actions/app';
|
2020-12-11 19:33:27 +01:00
|
|
|
import { withRouter } from 'react-router';
|
2021-03-31 21:07:11 +02:00
|
|
|
import { doResolveUris } from 'lbry-redux';
|
2020-12-11 19:33:27 +01:00
|
|
|
import analytics from 'analytics';
|
|
|
|
import Wunderbar from './view';
|
|
|
|
|
|
|
|
const select = (state, props) => ({
|
|
|
|
language: selectLanguage(state),
|
2021-03-31 21:07:11 +02:00
|
|
|
showMature: selectShowMatureContent(state),
|
2020-12-11 19:33:27 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const perform = (dispatch, ownProps) => ({
|
2021-03-31 21:07:11 +02:00
|
|
|
doResolveUris: (uris) => dispatch(doResolveUris(uris)),
|
2020-12-11 19:33:27 +01:00
|
|
|
doSearch: (query, options) => dispatch(doSearch(query, options)),
|
2021-03-31 21:07:11 +02:00
|
|
|
navigateToSearchPage: (query) => {
|
2020-12-11 19:33:27 +01:00
|
|
|
let encodedQuery = encodeURIComponent(query);
|
|
|
|
ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodedQuery}` });
|
|
|
|
analytics.apiLogSearch();
|
|
|
|
},
|
2021-03-31 21:07:11 +02:00
|
|
|
doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })),
|
2020-12-11 19:33:27 +01:00
|
|
|
doOpenMobileSearch: () => dispatch(doOpenModal(MODALS.MOBILE_SEARCH)),
|
2020-12-30 23:16:06 +01:00
|
|
|
doCloseMobileSearch: () => dispatch(doHideModal()),
|
2020-12-11 19:33:27 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
export default withRouter(connect(select, perform)(Wunderbar));
|