2016-10-30 13:13:05 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import ComposeForm from '../components/compose_form';
|
|
|
|
import {
|
|
|
|
changeCompose,
|
|
|
|
submitCompose,
|
|
|
|
cancelReplyCompose,
|
|
|
|
clearComposeSuggestions,
|
2016-11-12 08:33:21 -05:00
|
|
|
fetchComposeSuggestions,
|
|
|
|
selectComposeSuggestion
|
2016-10-30 13:13:05 -04:00
|
|
|
} from '../../../actions/compose';
|
|
|
|
import { makeGetStatus } from '../../../selectors';
|
2016-09-05 10:56:43 -04:00
|
|
|
|
2016-10-24 11:11:02 -04:00
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getStatus = makeGetStatus();
|
|
|
|
|
|
|
|
const mapStateToProps = function (state, props) {
|
|
|
|
return {
|
|
|
|
text: state.getIn(['compose', 'text']),
|
2016-11-12 08:33:21 -05:00
|
|
|
suggestion_token: state.getIn(['compose', 'suggestion_token']),
|
|
|
|
suggestions: state.getIn(['compose', 'suggestions']).toJS(),
|
2016-10-24 11:11:02 -04:00
|
|
|
is_submitting: state.getIn(['compose', 'is_submitting']),
|
|
|
|
is_uploading: state.getIn(['compose', 'is_uploading']),
|
|
|
|
in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to']))
|
|
|
|
};
|
2016-08-31 10:15:12 -04:00
|
|
|
};
|
2016-10-24 11:11:02 -04:00
|
|
|
|
|
|
|
return mapStateToProps;
|
2016-08-25 13:52:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = function (dispatch) {
|
|
|
|
return {
|
2016-10-30 13:13:05 -04:00
|
|
|
onChange (text) {
|
2016-08-31 10:15:12 -04:00
|
|
|
dispatch(changeCompose(text));
|
|
|
|
},
|
|
|
|
|
2016-10-30 13:13:05 -04:00
|
|
|
onSubmit () {
|
2016-08-31 10:15:12 -04:00
|
|
|
dispatch(submitCompose());
|
2016-08-31 16:58:10 -04:00
|
|
|
},
|
|
|
|
|
2016-10-30 13:13:05 -04:00
|
|
|
onCancelReply () {
|
2016-08-31 16:58:10 -04:00
|
|
|
dispatch(cancelReplyCompose());
|
2016-10-30 13:13:05 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onClearSuggestions () {
|
|
|
|
dispatch(clearComposeSuggestions());
|
|
|
|
},
|
|
|
|
|
|
|
|
onFetchSuggestions (token) {
|
|
|
|
dispatch(fetchComposeSuggestions(token));
|
2016-11-12 08:33:21 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
onSuggestionSelected (position, accountId) {
|
|
|
|
dispatch(selectComposeSuggestion(position, accountId));
|
2016-08-25 13:52:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-24 11:11:02 -04:00
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(ComposeForm);
|