about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/containers/reply_indicator_container.js
blob: dd6899be41855e204d5a2914877d31d1b331e83e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { connect } from 'react-redux';
import { cancelReplyCompose } from 'flavours/glitch/actions/compose';
import ReplyIndicator from '../components/reply_indicator';

const makeMapStateToProps = () => {
  const mapStateToProps = state => {
    let statusId = state.getIn(['compose', 'id'], null);
    let editing  = true;

    if (statusId === null) {
      statusId = state.getIn(['compose', 'in_reply_to']);
      editing  = false;
    }

    return {
      status: state.getIn(['statuses', statusId]),
      editing,
    };
  };

  return mapStateToProps;
};

const mapDispatchToProps = dispatch => ({

  onCancel () {
    dispatch(cancelReplyCompose());
  },

});

export default connect(makeMapStateToProps, mapDispatchToProps)(ReplyIndicator);