mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-06 11:34:59 -05:00
37 lines
973 B
TypeScript
37 lines
973 B
TypeScript
import IAIButton from 'common/components/IAIButton';
|
|
import { memo, useCallback } from 'react';
|
|
import { ControlNetConfig } from '../store/controlNetSlice';
|
|
import { useAppDispatch } from 'app/store/storeHooks';
|
|
import { controlNetImageProcessed } from '../store/actions';
|
|
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
|
|
|
type Props = {
|
|
controlNet: ControlNetConfig;
|
|
};
|
|
|
|
const ControlNetPreprocessButton = (props: Props) => {
|
|
const { controlNetId, controlImage } = props.controlNet;
|
|
const dispatch = useAppDispatch();
|
|
const isReady = useIsReadyToInvoke();
|
|
|
|
const handleProcess = useCallback(() => {
|
|
dispatch(
|
|
controlNetImageProcessed({
|
|
controlNetId,
|
|
})
|
|
);
|
|
}, [controlNetId, dispatch]);
|
|
|
|
return (
|
|
<IAIButton
|
|
size="sm"
|
|
onClick={handleProcess}
|
|
isDisabled={Boolean(!controlImage) || !isReady}
|
|
>
|
|
Preprocess
|
|
</IAIButton>
|
|
);
|
|
};
|
|
|
|
export default memo(ControlNetPreprocessButton);
|