fix(ui): staging area actions

This commit is contained in:
psychedelicious 2024-08-23 18:33:55 +10:00
parent cb97969bbc
commit 10a5452df9
4 changed files with 10 additions and 45 deletions

View File

@ -67,7 +67,7 @@ export const addStagingListeners = (startAppListening: AppStartListening) => {
objects: [imageObject],
};
api.dispatch(rasterLayerAdded({ overrides }));
api.dispatch(rasterLayerAdded({ overrides, isSelected: true }));
api.dispatch(sessionStagingAreaReset());
},
});

View File

@ -1,28 +0,0 @@
import { Button } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks';
import { allEntitiesDeleted } from 'features/controlLayers/store/canvasV2Slice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiTrashSimpleBold } from 'react-icons/pi';
export const ResetAllEntitiesButton = memo(() => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const onClick = useCallback(() => {
dispatch(allEntitiesDeleted());
}, [dispatch]);
return (
<Button
onClick={onClick}
leftIcon={<PiTrashSimpleBold />}
variant="ghost"
colorScheme="error"
data-testid="control-layers-delete-all-layers-button"
>
{t('controlLayers.resetAll')}
</Button>
);
});
ResetAllEntitiesButton.displayName = 'ResetAllEntitiesButton';

View File

@ -23,6 +23,7 @@ import {
PiTrashSimpleBold,
PiXBold,
} from 'react-icons/pi';
import { useChangeImageIsIntermediateMutation } from 'services/api/endpoints/images';
export const StagingAreaToolbar = memo(() => {
const dispatch = useAppDispatch();
@ -33,7 +34,7 @@ export const StagingAreaToolbar = memo(() => {
return images[session.selectedStagedImageIndex] ?? null;
}, [images, session.selectedStagedImageIndex]);
const isCanvasActive = useStore(INTERACTION_SCOPES.canvas.$isActive);
// const [changeIsImageIntermediate] = useChangeImageIsIntermediateMutation();
const [changeIsImageIntermediate] = useChangeImageIsIntermediateMutation();
const { t } = useTranslation();
@ -71,18 +72,12 @@ export const StagingAreaToolbar = memo(() => {
$shouldShowStagedImage.set(!shouldShowStagedImage);
}, [shouldShowStagedImage]);
const onSaveStagingImage = useCallback(
() => {
// if (!imageDTO) {
// return;
// }
// changeIsImageIntermediate({ imageDTO, is_intermediate: false });
},
[
// changeIsImageIntermediate,
// imageDTO
]
);
const onSaveStagingImage = useCallback(() => {
if (!selectedImage) {
return;
}
changeIsImageIntermediate({ imageDTO: selectedImage.imageDTO, is_intermediate: false });
}, [changeIsImageIntermediate, selectedImage]);
useHotkeys(
['left'],

View File

@ -162,7 +162,7 @@ export const imagesApi = api.injectEndpoints({
}),
invalidatesTags: (result, error, { imageDTO }) => {
const categories = getCategories(imageDTO);
const boardId = imageDTO.board_id ?? undefined;
const boardId = imageDTO.board_id ?? 'none';
return [
{ type: 'Image', id: imageDTO.image_name },
@ -557,8 +557,6 @@ export const {
useClearIntermediatesMutation,
useAddImagesToBoardMutation,
useRemoveImagesFromBoardMutation,
useAddImageToBoardMutation,
useRemoveImageFromBoardMutation,
useChangeImageIsIntermediateMutation,
useDeleteBoardAndImagesMutation,
useDeleteBoardMutation,