|
1 | 1 | import { Button, Flex, Text } from '@invoke-ai/ui-library'; |
2 | | -import { useAppDispatch } from 'app/store/storeHooks'; |
| 2 | +import { useAppStore } from 'app/store/nanostores/store'; |
3 | 3 | import { useImageUploadButton } from 'common/hooks/useImageUploadButton'; |
4 | 4 | import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext'; |
5 | 5 | import { useCanvasIsBusy } from 'features/controlLayers/hooks/useCanvasIsBusy'; |
| 6 | +import { replaceCanvasEntityObjectsWithImage } from 'features/imageActions/actions'; |
6 | 7 | import { activeTabCanvasRightPanelChanged } from 'features/ui/store/uiSlice'; |
7 | | -import { memo, useCallback, useMemo } from 'react'; |
| 8 | +import { memo, useCallback } from 'react'; |
8 | 9 | import { Trans } from 'react-i18next'; |
9 | | -import type { PostUploadAction } from 'services/api/types'; |
| 10 | +import type { ImageDTO } from 'services/api/types'; |
10 | 11 |
|
11 | 12 | export const ControlLayerSettingsEmptyState = memo(() => { |
12 | 13 | const entityIdentifier = useEntityIdentifierContext('control_layer'); |
13 | | - const dispatch = useAppDispatch(); |
| 14 | + const { dispatch, getState } = useAppStore(); |
14 | 15 | const isBusy = useCanvasIsBusy(); |
15 | | - const postUploadAction = useMemo<PostUploadAction>( |
16 | | - () => ({ type: 'REPLACE_LAYER_WITH_IMAGE', entityIdentifier }), |
17 | | - [entityIdentifier] |
| 16 | + const onUpload = useCallback( |
| 17 | + (imageDTO: ImageDTO) => { |
| 18 | + replaceCanvasEntityObjectsWithImage({ imageDTO, entityIdentifier, dispatch, getState }); |
| 19 | + }, |
| 20 | + [dispatch, entityIdentifier, getState] |
18 | 21 | ); |
19 | | - const uploadApi = useImageUploadButton({ postUploadAction }); |
| 22 | + const uploadApi = useImageUploadButton({ onUpload, allowMultiple: false }); |
20 | 23 | const onClickGalleryButton = useCallback(() => { |
21 | 24 | dispatch(activeTabCanvasRightPanelChanged('gallery')); |
22 | 25 | }, [dispatch]); |
|
0 commit comments