sforkowany z mirror/soapbox
Consistent behavior of compose modal close confirmation
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>emoji-improvements
rodzic
7d5a8ecf6f
commit
05d296f1ee
|
@ -14,13 +14,11 @@ const messages = defineMessages({
|
|||
confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||
});
|
||||
|
||||
const checkComposeContent = compose => {
|
||||
export const checkComposeContent = compose => {
|
||||
return [
|
||||
compose.text.length > 0,
|
||||
compose.spoiler_text.length > 0,
|
||||
compose.media_attachments.size > 0,
|
||||
compose.in_reply_to !== null,
|
||||
compose.quote !== null,
|
||||
compose.poll !== null,
|
||||
].some(check => check === true);
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||
|
||||
import { cancelReplyCompose } from 'soapbox/actions/compose';
|
||||
import { openModal, closeModal } from 'soapbox/actions/modals';
|
||||
import { checkComposeContent } from 'soapbox/components/modal_root';
|
||||
import { Modal } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
|
||||
|
@ -23,13 +24,13 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose }) => {
|
|||
const dispatch = useAppDispatch();
|
||||
|
||||
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 inReplyTo = useAppSelector((state) => state.compose.in_reply_to);
|
||||
const quote = useAppSelector((state) => state.compose.quote);
|
||||
|
||||
const onClickClose = () => {
|
||||
if (composeText) {
|
||||
if (hasComposeContent) {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
icon: require('@tabler/icons/trash.svg'),
|
||||
heading: statusId
|
||||
|
|
Ładowanie…
Reference in New Issue