import PropTypes from 'prop-types'; import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import { cancelReplyCompose } from '../../../actions/compose'; import { openModal, closeModal } from '../../../actions/modals'; import { Modal } from '../../../components/ui'; import ComposeFormContainer from '../../compose/containers/compose_form_container'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' }, }); const mapStateToProps = state => { const me = state.get('me'); return { account: state.getIn(['accounts', me]), composeText: state.getIn(['compose', 'text']), privacy: state.getIn(['compose', 'privacy']), inReplyTo: state.getIn(['compose', 'in_reply_to']), quote: state.getIn(['compose', 'quote']), }; }; class ComposeModal extends ImmutablePureComponent { static propTypes = { account: ImmutablePropTypes.map, intl: PropTypes.object.isRequired, onClose: PropTypes.func.isRequired, composeText: PropTypes.string, privacy: PropTypes.string, inReplyTo: PropTypes.string, quote: PropTypes.string, dispatch: PropTypes.func.isRequired, }; onClickClose = () => { const { composeText, dispatch, onClose, intl } = this.props; if (composeText) { dispatch(openModal('CONFIRM', { icon: require('@tabler/icons/icons/trash.svg'), heading: , message: , confirm: intl.formatMessage(messages.confirm), onConfirm: () => { dispatch(closeModal('COMPOSE')); dispatch(cancelReplyCompose()); }, })); } else { onClose('COMPOSE'); } }; renderTitle = () => { const { privacy, inReplyTo, quote } = this.props; if (privacy === 'direct') { return ; } else if (inReplyTo) { return ; } else if (quote) { return ; } else { return ; } } render() { return ( ); } } export default injectIntl(connect(mapStateToProps)(ComposeModal));