about summary refs log tree commit diff
path: root/app/assets/javascripts/components/features/compose/containers/unlisted_toggle_container.jsx
blob: ceac903d98d0ce2f7364da699bc61ac96d622d2c (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
import { connect } from 'react-redux';
import UnlistedToggle from '../components/unlisted_toggle';
import { makeGetStatus } from '../../../selectors';
import { changeComposeListability } from '../../../actions/compose';

const makeMapStateToProps = () => {
  const getStatus = makeGetStatus();

  const mapStateToProps = state => {
    const status = getStatus(state, state.getIn(['compose', 'in_reply_to']));
    const me     = state.getIn(['compose', 'me']);

    return {
      isPrivate: state.getIn(['compose', 'private']),
      isUnlisted: state.getIn(['compose', 'unlisted']),
      isReplyToOther: status ? status.getIn(['account', 'id']) !== me : false
    };
  };

  return mapStateToProps;
};

const mapDispatchToProps = dispatch => ({

  onChangeListability (e) {
    dispatch(changeComposeListability(e.target.checked));
  }

});

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