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.

66 lines
1.9 KiB

  1. import { connect } from 'react-redux';
  2. import ComposeForm from '../components/compose_form';
  3. import {
  4. changeCompose,
  5. submitCompose,
  6. clearComposeSuggestions,
  7. fetchComposeSuggestions,
  8. selectComposeSuggestion,
  9. changeComposeSpoilerText,
  10. insertEmojiCompose,
  11. uploadCompose,
  12. } from '../../../actions/compose';
  13. const mapStateToProps = state => ({
  14. text: state.getIn(['compose', 'text']),
  15. suggestions: state.getIn(['compose', 'suggestions']),
  16. spoiler: state.getIn(['compose', 'spoiler']),
  17. spoilerText: state.getIn(['compose', 'spoiler_text']),
  18. privacy: state.getIn(['compose', 'privacy']),
  19. focusDate: state.getIn(['compose', 'focusDate']),
  20. caretPosition: state.getIn(['compose', 'caretPosition']),
  21. preselectDate: state.getIn(['compose', 'preselectDate']),
  22. isSubmitting: state.getIn(['compose', 'is_submitting']),
  23. isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
  24. isUploading: state.getIn(['compose', 'is_uploading']),
  25. showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
  26. anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
  27. });
  28. const mapDispatchToProps = (dispatch) => ({
  29. onChange (text) {
  30. dispatch(changeCompose(text));
  31. },
  32. onSubmit (router) {
  33. dispatch(submitCompose(router));
  34. },
  35. onClearSuggestions () {
  36. dispatch(clearComposeSuggestions());
  37. },
  38. onFetchSuggestions (token) {
  39. dispatch(fetchComposeSuggestions(token));
  40. },
  41. onSuggestionSelected (position, token, suggestion, path) {
  42. dispatch(selectComposeSuggestion(position, token, suggestion, path));
  43. },
  44. onChangeSpoilerText (checked) {
  45. dispatch(changeComposeSpoilerText(checked));
  46. },
  47. onPaste (files) {
  48. dispatch(uploadCompose(files));
  49. },
  50. onPickEmoji (position, data, needsSpace) {
  51. dispatch(insertEmojiCompose(position, data, needsSpace));
  52. },
  53. });
  54. export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);