2019-03-06 05:53:37 +02:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-23 18:15:17 +03:00
|
|
|
|
2019-03-06 05:53:37 +02:00
|
|
|
import { addPoll, removePoll } from '../../../actions/compose';
|
2023-05-23 18:15:17 +03:00
|
|
|
import PollButton from '../components/poll_button';
|
2019-03-06 05:53:37 +02:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
unavailable: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 0),
|
|
|
|
active: state.getIn(['compose', 'poll']) !== null,
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
|
|
|
|
onClick () {
|
|
|
|
dispatch((_, getState) => {
|
|
|
|
if (getState().getIn(['compose', 'poll'])) {
|
|
|
|
dispatch(removePoll());
|
|
|
|
} else {
|
|
|
|
dispatch(addPoll());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(PollButton);
|