Revert "fix(ui): fix control image save button logic"

This reverts commit d8ce20c06f.
This commit is contained in:
psychedelicious 2023-08-30 12:12:54 +10:00
parent d8ce20c06f
commit 8014fc2f4f

View File

@ -15,7 +15,6 @@ import {
useAddImageToBoardMutation, useAddImageToBoardMutation,
useChangeImageIsIntermediateMutation, useChangeImageIsIntermediateMutation,
useGetImageDTOQuery, useGetImageDTOQuery,
useRemoveImageFromBoardMutation,
} from 'services/api/endpoints/images'; } from 'services/api/endpoints/images';
import { PostUploadAction } from 'services/api/types'; import { PostUploadAction } from 'services/api/types';
import IAIDndImageIcon from '../../../common/components/IAIDndImageIcon'; import IAIDndImageIcon from '../../../common/components/IAIDndImageIcon';
@ -68,36 +67,23 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
const [changeIsIntermediate] = useChangeImageIsIntermediateMutation(); const [changeIsIntermediate] = useChangeImageIsIntermediateMutation();
const [addToBoard] = useAddImageToBoardMutation(); const [addToBoard] = useAddImageToBoardMutation();
const [removeFromBoard] = useRemoveImageFromBoardMutation();
const handleResetControlImage = useCallback(() => { const handleResetControlImage = useCallback(() => {
dispatch(controlNetImageChanged({ controlNetId, controlImage: null })); dispatch(controlNetImageChanged({ controlNetId, controlImage: null }));
}, [controlNetId, dispatch]); }, [controlNetId, dispatch]);
const handleSaveControlImage = useCallback(async () => { const handleSaveControlImage = useCallback(() => {
if (!processedControlImage) { if (!processedControlImage) {
return; return;
} }
await changeIsIntermediate({ changeIsIntermediate({
imageDTO: processedControlImage, imageDTO: processedControlImage,
is_intermediate: false, is_intermediate: false,
}).unwrap(); });
if (autoAddBoardId !== 'none') { addToBoard({ imageDTO: processedControlImage, board_id: autoAddBoardId });
addToBoard({ }, [processedControlImage, autoAddBoardId, changeIsIntermediate, addToBoard]);
imageDTO: processedControlImage,
board_id: autoAddBoardId,
});
} else {
removeFromBoard({ imageDTO: processedControlImage });
}
}, [
processedControlImage,
changeIsIntermediate,
autoAddBoardId,
addToBoard,
removeFromBoard,
]);
const handleMouseEnter = useCallback(() => { const handleMouseEnter = useCallback(() => {
setIsMouseOverImage(true); setIsMouseOverImage(true);