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.

24 lines
684 B

  1. import { connect } from 'react-redux';
  2. import PollButton from '../components/poll_button';
  3. import { addPoll, removePoll } from '../../../actions/compose';
  4. const mapStateToProps = state => ({
  5. unavailable: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 0),
  6. active: state.getIn(['compose', 'poll']) !== null,
  7. });
  8. const mapDispatchToProps = dispatch => ({
  9. onClick () {
  10. dispatch((_, getState) => {
  11. if (getState().getIn(['compose', 'poll'])) {
  12. dispatch(removePoll());
  13. } else {
  14. dispatch(addPoll());
  15. }
  16. });
  17. },
  18. });
  19. export default connect(mapStateToProps, mapDispatchToProps)(PollButton);