bigbuffet-rw/app/soapbox/features/ui/containers/modal_container.js
marcin mikołajczak 7a35aa727b import from 'soapbox/…
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-05-30 20:23:55 +02:00

38 lines
845 B
JavaScript

import { connect } from 'react-redux';
import { cancelReplyCompose } from 'soapbox/actions/compose';
import { closeModal } from 'soapbox/actions/modals';
import { cancelReport } from 'soapbox/actions/reports';
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,
};
};
const mapDispatchToProps = (dispatch) => ({
onClose(type) {
switch (type) {
case 'COMPOSE':
dispatch(cancelReplyCompose());
break;
case 'REPORT':
dispatch(cancelReport());
break;
default:
break;
}
dispatch(closeModal(type));
},
});
export default connect(mapStateToProps, mapDispatchToProps)(ModalRoot);