The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

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