2019-03-06 12:53:37 +09:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-24 00:15:17 +09:00
|
|
|
|
2019-03-06 12:53:37 +09:00
|
|
|
import { addPoll, removePoll } from '../../../actions/compose';
|
2023-05-24 00:15:17 +09:00
|
|
|
import PollButton from '../components/poll_button';
|
2019-03-06 12:53:37 +09: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);
|