2017-12-21 18:08:54 -03:00
|
|
|
import { connect } from 'react-redux';
|
2020-07-27 16:04:12 -04:00
|
|
|
import { doToast, SETTINGS } from 'lbry-redux';
|
|
|
|
import { doSearch } from 'redux/actions/search';
|
|
|
|
import { selectIsSearching, makeSelectSearchUris, makeSelectQueryWithOptions } from 'redux/selectors/search';
|
2020-01-30 02:09:12 -05:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
2020-06-15 16:33:03 -04:00
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2019-06-11 14:10:58 -04:00
|
|
|
import analytics from 'analytics';
|
2017-12-21 18:08:54 -03:00
|
|
|
import SearchPage from './view';
|
2017-05-05 15:01:16 +07:00
|
|
|
|
2020-01-30 02:09:12 -05:00
|
|
|
const select = state => {
|
|
|
|
const showMature = makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state);
|
|
|
|
const query = makeSelectQueryWithOptions(
|
|
|
|
null,
|
|
|
|
showMature === false ? { nsfw: false, isBackgroundSearch: false } : { isBackgroundSearch: false }
|
|
|
|
)(state);
|
|
|
|
const uris = makeSelectSearchUris(query)(state);
|
|
|
|
|
|
|
|
return {
|
|
|
|
isSearching: selectIsSearching(state),
|
|
|
|
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
|
|
|
|
uris: uris,
|
2020-03-26 17:47:07 -04:00
|
|
|
isAuthenticated: selectUserVerifiedEmail(state),
|
2020-01-30 02:09:12 -05:00
|
|
|
};
|
|
|
|
};
|
2017-05-05 15:01:16 +07:00
|
|
|
|
2019-06-11 14:10:58 -04:00
|
|
|
const perform = dispatch => ({
|
2020-01-30 02:09:12 -05:00
|
|
|
search: (query, options) => dispatch(doSearch(query, options)),
|
2019-06-11 14:10:58 -04:00
|
|
|
onFeedbackPositive: query => {
|
|
|
|
analytics.apiSearchFeedback(query, 1);
|
|
|
|
dispatch(
|
|
|
|
doToast({
|
|
|
|
message: __('Thanks for the feedback! You help make the app better for everyone.'),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
onFeedbackNegative: query => {
|
|
|
|
analytics.apiSearchFeedback(query, 0);
|
|
|
|
dispatch(
|
|
|
|
doToast({
|
|
|
|
message: __(
|
|
|
|
'Thanks for the feedback. Mark has been notified and is currently walking over to his computer to work on this.'
|
|
|
|
),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2017-05-05 15:01:16 +07:00
|
|
|
|
2020-03-26 17:47:07 -04:00
|
|
|
export default connect(select, perform)(SearchPage);
|