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.

76 lines
2.0 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. changeComposeVisibility,
  12. changeComposeListability
  13. } from '../../../actions/compose';
  14. import { makeGetStatus } from '../../../selectors';
  15. const makeMapStateToProps = () => {
  16. const getStatus = makeGetStatus();
  17. const mapStateToProps = function (state, props) {
  18. return {
  19. text: state.getIn(['compose', 'text']),
  20. suggestion_token: state.getIn(['compose', 'suggestion_token']),
  21. suggestions: state.getIn(['compose', 'suggestions']),
  22. sensitive: state.getIn(['compose', 'sensitive']),
  23. unlisted: state.getIn(['compose', 'unlisted']),
  24. private: state.getIn(['compose', 'private']),
  25. is_submitting: state.getIn(['compose', 'is_submitting']),
  26. is_uploading: state.getIn(['compose', 'is_uploading']),
  27. in_reply_to: getStatus(state, state.getIn(['compose', 'in_reply_to']))
  28. };
  29. };
  30. return mapStateToProps;
  31. };
  32. const mapDispatchToProps = function (dispatch) {
  33. return {
  34. onChange (text) {
  35. dispatch(changeCompose(text));
  36. },
  37. onSubmit () {
  38. dispatch(submitCompose());
  39. },
  40. onCancelReply () {
  41. dispatch(cancelReplyCompose());
  42. },
  43. onClearSuggestions () {
  44. dispatch(clearComposeSuggestions());
  45. },
  46. onFetchSuggestions (token) {
  47. dispatch(fetchComposeSuggestions(token));
  48. },
  49. onSuggestionSelected (position, token, accountId) {
  50. dispatch(selectComposeSuggestion(position, token, accountId));
  51. },
  52. onChangeSensitivity (checked) {
  53. dispatch(changeComposeSensitivity(checked));
  54. },
  55. onChangeVisibility (checked) {
  56. dispatch(changeComposeVisibility(checked));
  57. },
  58. onChangeListability (checked) {
  59. dispatch(changeComposeListability(checked));
  60. }
  61. }
  62. };
  63. export default connect(makeMapStateToProps, mapDispatchToProps)(ComposeForm);