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.
 
 
 
 

67 lines
1.9 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. caretPosition: state.getIn(['compose', 'caretPosition']),
  22. preselectDate: state.getIn(['compose', 'preselectDate']),
  23. is_submitting: state.getIn(['compose', 'is_submitting']),
  24. is_uploading: 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 () {
  33. dispatch(submitCompose());
  34. },
  35. onClearSuggestions () {
  36. dispatch(clearComposeSuggestions());
  37. },
  38. onFetchSuggestions (token) {
  39. dispatch(fetchComposeSuggestions(token));
  40. },
  41. onSuggestionSelected (position, token, accountId) {
  42. dispatch(selectComposeSuggestion(position, token, accountId));
  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);