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.

77 lines
2.1 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. media_count: state.getIn(['compose', 'media_attachments']).size
  29. };
  30. };
  31. return mapStateToProps;
  32. };
  33. const mapDispatchToProps = function (dispatch) {
  34. return {
  35. onChange (text) {
  36. dispatch(changeCompose(text));
  37. },
  38. onSubmit () {
  39. dispatch(submitCompose());
  40. },
  41. onCancelReply () {
  42. dispatch(cancelReplyCompose());
  43. },
  44. onClearSuggestions () {
  45. dispatch(clearComposeSuggestions());
  46. },
  47. onFetchSuggestions (token) {
  48. dispatch(fetchComposeSuggestions(token));
  49. },
  50. onSuggestionSelected (position, token, accountId) {
  51. dispatch(selectComposeSuggestion(position, token, accountId));
  52. },
  53. onChangeSensitivity (checked) {
  54. dispatch(changeComposeSensitivity(checked));
  55. },
  56. onChangeVisibility (checked) {
  57. dispatch(changeComposeVisibility(checked));
  58. },
  59. onChangeListability (checked) {
  60. dispatch(changeComposeListability(checked));
  61. }
  62. }
  63. };
  64. export default connect(makeMapStateToProps, mapDispatchToProps)(ComposeForm);