2020-03-27 13:59:38 -07:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-05-11 06:25:48 -07:00
|
|
|
import { cancelReport } from 'soapbox/actions/reports';
|
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
import { cancelReplyCompose } from '../../../actions/compose';
|
2022-02-02 05:33:12 -08:00
|
|
|
import { closeModal } from '../../../actions/modals';
|
2020-03-27 13:59:38 -07:00
|
|
|
import ModalRoot from '../components/modal_root';
|
|
|
|
|
2022-01-30 09:46:57 -08:00
|
|
|
const mapStateToProps = state => {
|
2022-02-02 05:33:12 -08:00
|
|
|
const modal = state.get('modals').last({
|
2022-01-30 09:46:57 -08:00
|
|
|
modalType: null,
|
|
|
|
modalProps: {},
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: modal.modalType,
|
|
|
|
props: modal.modalProps,
|
|
|
|
};
|
|
|
|
};
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2022-01-30 09:46:57 -08:00
|
|
|
onClose(type) {
|
2022-05-11 06:25:48 -07:00
|
|
|
switch (type) {
|
2022-05-12 12:32:32 -07:00
|
|
|
case 'COMPOSE':
|
|
|
|
dispatch(cancelReplyCompose());
|
|
|
|
break;
|
|
|
|
case 'REPORT':
|
|
|
|
dispatch(cancelReport());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
2022-01-30 09:46:57 -08:00
|
|
|
dispatch(closeModal(type));
|
2020-03-27 13:59:38 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ModalRoot);
|