bigbuffet-rw/app/soapbox/features/ui/containers/modal_container.js

39 lines
847 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import { connect } from 'react-redux';
import { cancelReport } from 'soapbox/actions/reports';
2020-03-27 13:59:38 -07:00
import { cancelReplyCompose } from '../../../actions/compose';
import { closeModal } from '../../../actions/modals';
2020-03-27 13:59:38 -07:00
import ModalRoot from '../components/modal_root';
const mapStateToProps = state => {
const modal = state.get('modals').last({
modalType: null,
modalProps: {},
});
return {
type: modal.modalType,
props: modal.modalProps,
};
};
2020-03-27 13:59:38 -07:00
const mapDispatchToProps = (dispatch) => ({
onClose(type) {
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
}
dispatch(closeModal(type));
2020-03-27 13:59:38 -07:00
},
});
export default connect(mapStateToProps, mapDispatchToProps)(ModalRoot);