@@ -30,6 +30,13 @@ import { setShouldConfirmOnDelete, SystemState } from '../system/systemSlice';
3030import * as InvokeAI from '../../app/invokeai' ;
3131import { useHotkeys } from 'react-hotkeys-hook' ;
3232
33+ const systemSelector = createSelector (
34+ ( state : RootState ) => state . system ,
35+ ( system : SystemState ) => {
36+ const { shouldConfirmOnDelete, isConnected, isProcessing } = system ;
37+ return { shouldConfirmOnDelete, isConnected, isProcessing } ;
38+ }
39+ ) ;
3340interface DeleteImageModalProps {
3441 /**
3542 * Component which, on click, should delete the image/open the modal.
@@ -41,11 +48,6 @@ interface DeleteImageModalProps {
4148 image : InvokeAI . Image ;
4249}
4350
44- const systemSelector = createSelector (
45- ( state : RootState ) => state . system ,
46- ( system : SystemState ) => system . shouldConfirmOnDelete
47- ) ;
48-
4951/**
5052 * Needs a child, which will act as the button to delete an image.
5153 * If system.shouldConfirmOnDelete is true, a confirmation modal is displayed.
@@ -56,23 +58,19 @@ const DeleteImageModal = forwardRef(
5658 ( { image, children } : DeleteImageModalProps , ref ) => {
5759 const { isOpen, onOpen, onClose } = useDisclosure ( ) ;
5860 const dispatch = useAppDispatch ( ) ;
59- const shouldConfirmOnDelete = useAppSelector ( systemSelector ) ;
61+ const { shouldConfirmOnDelete, isConnected, isProcessing } =
62+ useAppSelector ( systemSelector ) ;
6063 const cancelRef = useRef < HTMLButtonElement > ( null ) ;
61- const toast = useToast ( ) ;
6264
6365 const handleClickDelete = ( e : SyntheticEvent ) => {
6466 e . stopPropagation ( ) ;
6567 shouldConfirmOnDelete ? onOpen ( ) : handleDelete ( ) ;
6668 } ;
6769
6870 const handleDelete = ( ) => {
69- dispatch ( deleteImage ( image ) ) ;
70- toast ( {
71- title : 'Image Deleted' ,
72- status : 'success' ,
73- duration : 2500 ,
74- isClosable : true ,
75- } ) ;
71+ if ( isConnected && ! isProcessing ) {
72+ dispatch ( deleteImage ( image ) ) ;
73+ }
7674 onClose ( ) ;
7775 } ;
7876
0 commit comments