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 { uploadCompose } from '../../../actions/compose';
  4. import {
  5. changeCompose,
  6. submitCompose,
  7. clearComposeSuggestions,
  8. fetchComposeSuggestions,
  9. selectComposeSuggestion,
  10. changeComposeSpoilerText,
  11. insertEmojiCompose
  12. } from '../../../actions/compose';
  13. const mapStateToProps = state => ({
  14. text: state.getIn(['compose', 'text']),
  15. suggestion_token: state.getIn(['compose', 'suggestion_token']),
  16. suggestions: state.getIn(['compose', 'suggestions']),
  17. spoiler: state.getIn(['compose', 'spoiler']),
  18. spoiler_text: state.getIn(['compose', 'spoiler_text']),
  19. privacy: state.getIn(['compose', 'privacy']),
  20. focusDate: state.getIn(['compose', 'focusDate']),
  21. preselectDate: state.getIn(['compose', 'preselectDate']),
  22. is_submitting: state.getIn(['compose', 'is_submitting']),
  23. is_uploading: state.getIn(['compose', 'is_uploading']),
  24. me: state.getIn(['compose', 'me'])
  25. });
  26. const mapDispatchToProps = (dispatch) => ({
  27. onChange (text) {
  28. dispatch(changeCompose(text));
  29. },
  30. onSubmit () {
  31. dispatch(submitCompose());
  32. },
  33. onClearSuggestions () {
  34. dispatch(clearComposeSuggestions());
  35. },
  36. onFetchSuggestions (token) {
  37. dispatch(fetchComposeSuggestions(token));
  38. },
  39. onSuggestionSelected (position, token, accountId) {
  40. dispatch(selectComposeSuggestion(position, token, accountId));
  41. },
  42. onChangeSpoilerText (checked) {
  43. dispatch(changeComposeSpoilerText(checked));
  44. },
  45. onPaste (files) {
  46. dispatch(uploadCompose(files));
  47. },
  48. onPickEmoji (position, data) {
  49. dispatch(insertEmojiCompose(position, data));
  50. },
  51. });
  52. export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);