Merge commit '40242fafee83cf9a6bcb2d0ac1e228827969402f' into glitch-soc/merge-upstream
This commit is contained in:
commit
6abe6cdef5
46 files changed
+441
-58
No files matched your search
@@ -251,12 +251,31 @@ class Status extends ImmutablePureComponent {
|
||||
};
|
||||
|
||||
handleDeleteClick = (status, withRedraft = false) => {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, history } = this.props;
|
||||
|
||||
const handleDeleteSuccess = () => {
|
||||
history.push('/');
|
||||
};
|
||||
|
||||
if (!deleteModal) {
|
||||
dispatch(deleteStatus(status.get('id'), withRedraft));
|
||||
dispatch(deleteStatus(status.get('id'), withRedraft))
|
||||
.then(() => {
|
||||
if (!withRedraft) {
|
||||
handleDeleteSuccess();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// Error handling - could show error message
|
||||
});
|
||||
} else {
|
||||
dispatch(openModal({ modalType: 'CONFIRM_DELETE_STATUS', modalProps: { statusId: status.get('id'), withRedraft } }));
|
||||
dispatch(openModal({
|
||||
modalType: 'CONFIRM_DELETE_STATUS',
|
||||
modalProps: {
|
||||
statusId: status.get('id'),
|
||||
withRedraft,
|
||||
onDeleteSuccess: handleDeleteSuccess
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+12
-3
@@ -40,14 +40,23 @@ export const ConfirmDeleteStatusModal: React.FC<
|
||||
{
|
||||
statusId: string;
|
||||
withRedraft: boolean;
|
||||
onDeleteSuccess?: () => void;
|
||||
} & BaseConfirmationModalProps
|
||||
> = ({ statusId, withRedraft, onClose }) => {
|
||||
> = ({ statusId, withRedraft, onClose, onDeleteSuccess }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const onConfirm = useCallback(() => {
|
||||
dispatch(deleteStatus(statusId, withRedraft));
|
||||
}, [dispatch, statusId, withRedraft]);
|
||||
void dispatch(deleteStatus(statusId, withRedraft))
|
||||
.then(() => {
|
||||
onDeleteSuccess?.();
|
||||
onClose();
|
||||
})
|
||||
.catch(() => {
|
||||
// Error handling - still close modal
|
||||
onClose();
|
||||
});
|
||||
}, [dispatch, statusId, withRedraft, onDeleteSuccess, onClose]);
|
||||
|
||||
return (
|
||||
<ConfirmationModal
|
||||
|
||||
Reference in new issue
Block a user