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.

42 lines
1.1 KiB

  1. import { connect } from 'react-redux';
  2. import ComposeForm from '../components/compose_form';
  3. import { changeCompose, submitCompose, cancelReplyCompose } from '../actions/compose';
  4. function selectStatus(state) {
  5. let statusId = state.getIn(['compose', 'in_reply_to'], null);
  6. if (statusId === null) {
  7. return null;
  8. }
  9. let status = state.getIn(['timelines', 'statuses', statusId]);
  10. status = status.set('account', state.getIn(['timelines', 'accounts', status.get('account')]));
  11. return status;
  12. };
  13. const mapStateToProps = function (state, props) {
  14. return {
  15. text: state.getIn(['compose', 'text']),
  16. is_submitting: state.getIn(['compose', 'is_submitting']),
  17. in_reply_to: selectStatus(state)
  18. };
  19. };
  20. const mapDispatchToProps = function (dispatch) {
  21. return {
  22. onChange: function (text) {
  23. dispatch(changeCompose(text));
  24. },
  25. onSubmit: function () {
  26. dispatch(submitCompose());
  27. },
  28. onCancelReply: function () {
  29. dispatch(cancelReplyCompose());
  30. }
  31. }
  32. };
  33. export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);