2019-02-18 18:24:56 +01:00
|
|
|
import { connect } from 'react-redux';
|
2019-05-07 23:38:29 +02:00
|
|
|
import { selectSearchOptions, doUpdateSearchOptions, makeSelectQueryWithOptions, doToast } from 'lbry-redux';
|
2019-02-21 23:45:17 +01:00
|
|
|
import { doToggleSearchExpanded } from 'redux/actions/app';
|
|
|
|
import { selectSearchOptionsExpanded } from 'redux/selectors/app';
|
|
|
|
import analytics from 'analytics';
|
2019-02-18 18:24:56 +01:00
|
|
|
import SearchOptions from './view';
|
|
|
|
|
|
|
|
const select = state => ({
|
|
|
|
options: selectSearchOptions(state),
|
2019-02-21 23:45:17 +01:00
|
|
|
expanded: selectSearchOptionsExpanded(state),
|
|
|
|
query: makeSelectQueryWithOptions()(state),
|
2019-02-18 18:24:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const perform = dispatch => ({
|
|
|
|
setSearchOption: (option, value) => dispatch(doUpdateSearchOptions({ [option]: value })),
|
2019-02-21 23:45:17 +01:00
|
|
|
toggleSearchExpanded: () => dispatch(doToggleSearchExpanded()),
|
|
|
|
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.'
|
|
|
|
),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
2019-02-18 18:24:56 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
select,
|
|
|
|
perform
|
|
|
|
)(SearchOptions);
|