mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): use custom hook in current image buttons
Already in use elsewhere, forgot to use it here.
This commit is contained in:
parent
b9a1374b8f
commit
d699efa5bc
@ -18,7 +18,6 @@ import { DeleteImageButton } from 'features/deleteImageModal/components/DeleteIm
|
|||||||
import { imagesToDeleteSelected } from 'features/deleteImageModal/store/slice';
|
import { imagesToDeleteSelected } from 'features/deleteImageModal/store/slice';
|
||||||
import SingleSelectionMenuItems from 'features/gallery/components/ImageContextMenu/SingleSelectionMenuItems';
|
import SingleSelectionMenuItems from 'features/gallery/components/ImageContextMenu/SingleSelectionMenuItems';
|
||||||
import { sentImageToImg2Img } from 'features/gallery/store/actions';
|
import { sentImageToImg2Img } from 'features/gallery/store/actions';
|
||||||
import { workflowLoadRequested } from 'features/nodes/store/actions';
|
|
||||||
import ParamUpscalePopover from 'features/parameters/components/Parameters/Upscale/ParamUpscaleSettings';
|
import ParamUpscalePopover from 'features/parameters/components/Parameters/Upscale/ParamUpscaleSettings';
|
||||||
import { useRecallParameters } from 'features/parameters/hooks/useRecallParameters';
|
import { useRecallParameters } from 'features/parameters/hooks/useRecallParameters';
|
||||||
import { initialImageSelected } from 'features/parameters/store/actions';
|
import { initialImageSelected } from 'features/parameters/store/actions';
|
||||||
@ -29,6 +28,7 @@ import {
|
|||||||
setShouldShowImageDetails,
|
setShouldShowImageDetails,
|
||||||
setShouldShowProgressInViewer,
|
setShouldShowProgressInViewer,
|
||||||
} from 'features/ui/store/uiSlice';
|
} from 'features/ui/store/uiSlice';
|
||||||
|
import { useGetAndLoadEmbeddedWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadEmbeddedWorkflow';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -41,10 +41,7 @@ import {
|
|||||||
FaSeedling,
|
FaSeedling,
|
||||||
} from 'react-icons/fa';
|
} from 'react-icons/fa';
|
||||||
import { FaCircleNodes, FaEllipsis } from 'react-icons/fa6';
|
import { FaCircleNodes, FaEllipsis } from 'react-icons/fa6';
|
||||||
import {
|
import { useGetImageDTOQuery } from 'services/api/endpoints/images';
|
||||||
useGetImageDTOQuery,
|
|
||||||
useLazyGetImageWorkflowQuery,
|
|
||||||
} from 'services/api/endpoints/images';
|
|
||||||
import { useDebouncedMetadata } from 'services/api/hooks/useDebouncedMetadata';
|
import { useDebouncedMetadata } from 'services/api/hooks/useDebouncedMetadata';
|
||||||
import { menuListMotionProps } from 'theme/components/menu';
|
import { menuListMotionProps } from 'theme/components/menu';
|
||||||
|
|
||||||
@ -113,15 +110,15 @@ const CurrentImageButtons = () => {
|
|||||||
lastSelectedImage?.image_name
|
lastSelectedImage?.image_name
|
||||||
);
|
);
|
||||||
|
|
||||||
const [getWorkflow, getWorkflowResult] = useLazyGetImageWorkflowQuery();
|
const { getAndLoadEmbeddedWorkflow, getAndLoadEmbeddedWorkflowResult } =
|
||||||
|
useGetAndLoadEmbeddedWorkflow({});
|
||||||
|
|
||||||
const handleLoadWorkflow = useCallback(() => {
|
const handleLoadWorkflow = useCallback(() => {
|
||||||
if (!lastSelectedImage) {
|
if (!lastSelectedImage || !lastSelectedImage.has_workflow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getWorkflow(lastSelectedImage?.image_name).then((workflow) => {
|
getAndLoadEmbeddedWorkflow(lastSelectedImage.image_name);
|
||||||
dispatch(workflowLoadRequested(workflow.data));
|
}, [getAndLoadEmbeddedWorkflow, lastSelectedImage]);
|
||||||
});
|
|
||||||
}, [dispatch, getWorkflow, lastSelectedImage]);
|
|
||||||
|
|
||||||
useHotkeys('w', handleLoadWorkflow, [lastSelectedImage]);
|
useHotkeys('w', handleLoadWorkflow, [lastSelectedImage]);
|
||||||
|
|
||||||
@ -261,7 +258,7 @@ const CurrentImageButtons = () => {
|
|||||||
aria-label={`${t('nodes.loadWorkflow')} (W)`}
|
aria-label={`${t('nodes.loadWorkflow')} (W)`}
|
||||||
isDisabled={!imageDTO?.has_workflow}
|
isDisabled={!imageDTO?.has_workflow}
|
||||||
onClick={handleLoadWorkflow}
|
onClick={handleLoadWorkflow}
|
||||||
isLoading={getWorkflowResult.isLoading}
|
isLoading={getAndLoadEmbeddedWorkflowResult.isLoading}
|
||||||
/>
|
/>
|
||||||
<IAIIconButton
|
<IAIIconButton
|
||||||
isLoading={isLoadingMetadata}
|
isLoading={isLoadingMetadata}
|
||||||
|
Loading…
Reference in New Issue
Block a user