Merge branch 'close-compose-modal' into 'develop'

Consistent behavior of compose modal close confirmation

See merge request soapbox-pub/soapbox-fe!1758
This commit is contained in:
marcin mikołajczak 2022-08-31 04:56:20 +00:00
commit 7f99568c73
2 changed files with 3 additions and 2 deletions

Binary file not shown.

View file

@ -3,6 +3,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { cancelReplyCompose } from 'soapbox/actions/compose'; import { cancelReplyCompose } from 'soapbox/actions/compose';
import { openModal, closeModal } from 'soapbox/actions/modals'; import { openModal, closeModal } from 'soapbox/actions/modals';
import { checkComposeContent } from 'soapbox/components/modal_root';
import { Modal } from 'soapbox/components/ui'; import { Modal } from 'soapbox/components/ui';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
@ -23,13 +24,13 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose }) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const statusId = useAppSelector((state) => state.compose.id); const statusId = useAppSelector((state) => state.compose.id);
const composeText = useAppSelector((state) => state.compose.text); const hasComposeContent = useAppSelector((state) => checkComposeContent(state.compose));
const privacy = useAppSelector((state) => state.compose.privacy); const privacy = useAppSelector((state) => state.compose.privacy);
const inReplyTo = useAppSelector((state) => state.compose.in_reply_to); const inReplyTo = useAppSelector((state) => state.compose.in_reply_to);
const quote = useAppSelector((state) => state.compose.quote); const quote = useAppSelector((state) => state.compose.quote);
const onClickClose = () => { const onClickClose = () => {
if (composeText) { if (hasComposeContent) {
dispatch(openModal('CONFIRM', { dispatch(openModal('CONFIRM', {
icon: require('@tabler/icons/trash.svg'), icon: require('@tabler/icons/trash.svg'),
heading: statusId heading: statusId