bigbuffet-rw/app/soapbox/features/compose/containers/schedule_button_container.js

26 lines
665 B
JavaScript
Raw Normal View History

2021-06-18 09:04:31 -07:00
import { connect } from 'react-redux';
2021-06-18 09:04:31 -07:00
import { addSchedule, removeSchedule } from '../../../actions/compose';
import ScheduleButton from '../components/schedule_button';
2021-06-18 09:04:31 -07:00
const mapStateToProps = state => ({
active: state.getIn(['compose', 'schedule']) ? true : false,
unavailable: !!state.getIn(['compose', 'id']),
2021-06-18 09:04:31 -07:00
});
const mapDispatchToProps = dispatch => ({
onClick() {
dispatch((dispatch, getState) => {
2021-06-18 09:04:31 -07:00
if (getState().getIn(['compose', 'schedule'])) {
dispatch(removeSchedule());
} else {
dispatch(addSchedule());
}
});
},
});
export default connect(mapStateToProps, mapDispatchToProps)(ScheduleButton);