fix: Processing Control Image not saving properly

This commit is contained in:
blessedcoolant 2023-08-30 02:09:13 +12:00
parent d251124196
commit 15a927b517

View File

@ -11,7 +11,11 @@ import {
} from 'features/dnd/types'; } from 'features/dnd/types';
import { memo, useCallback, useMemo, useState } from 'react'; import { memo, useCallback, useMemo, useState } from 'react';
import { FaSave, FaUndo } from 'react-icons/fa'; import { FaSave, FaUndo } from 'react-icons/fa';
import { imagesApi, useGetImageDTOQuery } from 'services/api/endpoints/images'; import {
useAddImageToBoardMutation,
useChangeImageIsIntermediateMutation,
useGetImageDTOQuery,
} 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';
import { import {
@ -61,6 +65,9 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
processedControlImageName ?? skipToken processedControlImageName ?? skipToken
); );
const [changeIsIntermediate] = useChangeImageIsIntermediateMutation();
const [addToBoard] = useAddImageToBoardMutation();
const handleResetControlImage = useCallback(() => { const handleResetControlImage = useCallback(() => {
dispatch(controlNetImageChanged({ controlNetId, controlImage: null })); dispatch(controlNetImageChanged({ controlNetId, controlImage: null }));
}, [controlNetId, dispatch]); }, [controlNetId, dispatch]);
@ -70,36 +77,13 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
return; return;
} }
dispatch( changeIsIntermediate({
imagesApi.endpoints.addImageToBoard.initiate({ imageDTO: processedControlImage,
board_id: autoAddBoardId,
imageDTO: {
...processedControlImage,
is_intermediate: false, is_intermediate: false,
}, });
})
);
// THIS PART WORKS addToBoard({ imageDTO: processedControlImage, board_id: autoAddBoardId });
// fetch(processedControlImage.image_url) }, [processedControlImage, autoAddBoardId, changeIsIntermediate, addToBoard]);
// .then((res) => res.blob())
// .then((blob) => {
// dispatch(
// imagesApi.endpoints.uploadImage.initiate({
// file: new File([blob], processedControlImage.image_name, {
// type: 'image/png',
// }),
// image_category: processedControlImage.image_category,
// is_intermediate: false,
// board_id: autoAddBoardId === 'none' ? undefined : autoAddBoardId,
// postUploadAction: {
// type: 'TOAST',
// toastOptions: { title: 'Processed Image Saved to Assets' },
// },
// })
// );
// });
}, [processedControlImage, autoAddBoardId, dispatch]);
const handleMouseEnter = useCallback(() => { const handleMouseEnter = useCallback(() => {
setIsMouseOverImage(true); setIsMouseOverImage(true);