1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-15 23:28:31 +09:00
YuruToot/app/javascript/mastodon/features/compose/containers/search_container.js

60 lines
1.1 KiB
JavaScript
Raw Normal View History

import { createSelector } from '@reduxjs/toolkit';
2016-11-13 21:04:18 +09:00
import { connect } from 'react-redux';
2016-11-13 21:04:18 +09:00
import {
changeSearch,
2017-04-01 02:59:54 +09:00
clearSearch,
submitSearch,
showSearch,
openURL,
clickSearchResult,
forgetSearchResult,
} from 'mastodon/actions/search';
2016-11-13 21:04:18 +09:00
import Search from '../components/search';
const getRecentSearches = createSelector(
state => state.getIn(['search', 'recent']),
recent => recent.reverse(),
);
2016-11-13 21:04:18 +09:00
const mapStateToProps = state => ({
2017-04-01 05:44:12 +09:00
value: state.getIn(['search', 'value']),
submitted: state.getIn(['search', 'submitted']),
recent: getRecentSearches(state),
2016-11-13 21:04:18 +09:00
});
const mapDispatchToProps = dispatch => ({
onChange (value) {
dispatch(changeSearch(value));
},
onClear () {
2017-04-01 02:59:54 +09:00
dispatch(clearSearch());
2016-11-13 21:04:18 +09:00
},
onSubmit (type) {
dispatch(submitSearch(type));
2016-11-13 21:04:18 +09:00
},
2017-04-01 02:59:54 +09:00
onShow () {
dispatch(showSearch());
},
2016-11-13 21:04:18 +09:00
onOpenURL (q, routerHistory) {
dispatch(openURL(q, routerHistory));
},
onClickSearchResult (q, type) {
dispatch(clickSearchResult(q, type));
},
onForgetSearchResult (q) {
dispatch(forgetSearchResult(q));
},
2016-11-13 21:04:18 +09:00
});
export default connect(mapStateToProps, mapDispatchToProps)(Search);