1- import { Flex , useShiftModifier } from '@invoke-ai/ui-library' ;
1+ import { Flex } from '@invoke-ai/ui-library' ;
22import { useStore } from '@nanostores/react' ;
33import { skipToken } from '@reduxjs/toolkit/query' ;
4- import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
54import IAIDndImage from 'common/components/IAIDndImage' ;
65import IAIDndImageIcon from 'common/components/IAIDndImageIcon' ;
76import { useNanoid } from 'common/hooks/useNanoid' ;
8- import { bboxHeightChanged , bboxWidthChanged } from 'features/controlLayers/store/canvasSlice' ;
9- import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice' ;
10- import { selectOptimalDimension } from 'features/controlLayers/store/selectors' ;
117import type { ImageWithDims } from 'features/controlLayers/store/types' ;
128import type { ImageDraggableData , TypesafeDroppableData } from 'features/dnd/types' ;
13- import { calculateNewSize } from 'features/parameters/components/Bbox/calculateNewSize' ;
149import { memo , useCallback , useEffect , useMemo } from 'react' ;
1510import { useTranslation } from 'react-i18next' ;
16- import { PiArrowCounterClockwiseBold , PiRulerBold } from 'react-icons/pi' ;
11+ import { PiArrowCounterClockwiseBold } from 'react-icons/pi' ;
1712import { useGetImageDTOQuery } from 'services/api/endpoints/images' ;
1813import type { ImageDTO , PostUploadAction } from 'services/api/types' ;
1914import { $isConnected } from 'services/events/stores' ;
@@ -27,11 +22,7 @@ type Props = {
2722
2823export const IPAdapterImagePreview = memo ( ( { image, onChangeImage, droppableData, postUploadAction } : Props ) => {
2924 const { t } = useTranslation ( ) ;
30- const dispatch = useAppDispatch ( ) ;
31- const isStaging = useAppSelector ( selectIsStaging ) ;
3225 const isConnected = useStore ( $isConnected ) ;
33- const optimalDimension = useAppSelector ( selectOptimalDimension ) ;
34- const shift = useShiftModifier ( ) ;
3526 const dndId = useNanoid ( 'ip_adapter_image_preview' ) ;
3627
3728 const { currentData : controlImage , isError : isErrorControlImage } = useGetImageDTOQuery (
@@ -41,26 +32,6 @@ export const IPAdapterImagePreview = memo(({ image, onChangeImage, droppableData
4132 onChangeImage ( null ) ;
4233 } , [ onChangeImage ] ) ;
4334
44- const handleSetControlImageToDimensions = useCallback ( ( ) => {
45- if ( ! controlImage ) {
46- return ;
47- }
48-
49- const options = { updateAspectRatio : true , clamp : true } ;
50- if ( shift ) {
51- const { width, height } = controlImage ;
52- dispatch ( bboxWidthChanged ( { width, ...options } ) ) ;
53- dispatch ( bboxHeightChanged ( { height, ...options } ) ) ;
54- } else {
55- const { width, height } = calculateNewSize (
56- controlImage . width / controlImage . height ,
57- optimalDimension * optimalDimension
58- ) ;
59- dispatch ( bboxWidthChanged ( { width, ...options } ) ) ;
60- dispatch ( bboxHeightChanged ( { height, ...options } ) ) ;
61- }
62- } , [ controlImage , dispatch , optimalDimension , shift ] ) ;
63-
6435 const draggableData = useMemo < ImageDraggableData | undefined > ( ( ) => {
6536 if ( controlImage ) {
6637 return {
@@ -93,12 +64,6 @@ export const IPAdapterImagePreview = memo(({ image, onChangeImage, droppableData
9364 icon = { < PiArrowCounterClockwiseBold size = { 16 } /> }
9465 tooltip = { t ( 'common.reset' ) }
9566 />
96- < IAIDndImageIcon
97- onClick = { handleSetControlImageToDimensions }
98- icon = { < PiRulerBold size = { 16 } /> }
99- tooltip = { shift ? t ( 'controlLayers.useSizeIgnoreModel' ) : t ( 'controlLayers.useSizeOptimizeForModel' ) }
100- isDisabled = { isStaging }
101- />
10267 </ Flex >
10368 ) }
10469 </ Flex >
0 commit comments