You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.7 KiB

  1. import { connect } from 'react-redux';
  2. import ComposeForm from '../components/compose_form';
  3. import {
  4. changeCompose,
  5. submitCompose,
  6. cancelReplyCompose,
  7. clearComposeSuggestions,
  8. fetchComposeSuggestions,
  9. selectComposeSuggestion,
  10. changeComposeSensitivity
  11. } from '../../../actions/compose';
  12. import { makeGetStatus } from '../../../selectors';
  13. const makeMapStateToProps = () => {
  14. const getStatus = makeGetStatus();
  15. const mapStateToProps = function (state, props) {
  16. return {
  17. text: state.getIn(['compose', 'text']),
  18. suggestion_token: state.getIn(['compose', 'suggestion_token']),
  19. suggestions: state.getIn(['compose', 'suggestions']).toJS(),
  20. sensitive: state.getIn(['compose', 'sensitive']),
  21. is_submitting: state.getIn(['compose', 'is_submitting']),
  22. is_uploading: state.getIn(['compose', 'is_uploading']),
  23. in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to']))
  24. };
  25. };
  26. return mapStateToProps;
  27. };
  28. const mapDispatchToProps = function (dispatch) {
  29. return {
  30. onChange (text) {
  31. dispatch(changeCompose(text));
  32. },
  33. onSubmit () {
  34. dispatch(submitCompose());
  35. },
  36. onCancelReply () {
  37. dispatch(cancelReplyCompose());
  38. },
  39. onClearSuggestions () {
  40. dispatch(clearComposeSuggestions());
  41. },
  42. onFetchSuggestions (token) {
  43. dispatch(fetchComposeSuggestions(token));
  44. },
  45. onSuggestionSelected (position, accountId) {
  46. dispatch(selectComposeSuggestion(position, accountId));
  47. },
  48. onChangeSensitivity (checked) {
  49. dispatch(changeComposeSensitivity(checked));
  50. }
  51. }
  52. };
  53. export default connect(makeMapStateToProps, mapDispatchToProps)(ComposeForm);