poll_button_container.js 682 B

12345678910111213141516171819202122232425
  1. import { connect } from 'react-redux';
  2. import { addPoll, removePoll } from '../../../actions/compose';
  3. import PollButton from '../components/poll_button';
  4. const mapStateToProps = state => ({
  5. disabled: 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);