From c69573e65deb87e8409d6087eda7fd8a36c688de Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 18 Nov 2022 20:02:06 +1100
Subject: [PATCH] Disables canvas actions which cannot be done during
processing
---
.../IAICanvasToolbar/IAICanvasToolbar.tsx | 35 +++++++++++--------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/frontend/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx b/frontend/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx
index ebad47cd12..925a5e86d2 100644
--- a/frontend/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx
+++ b/frontend/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx
@@ -31,18 +31,19 @@ import {
isStagingSelector,
} from 'features/canvas/store/canvasSelectors';
import { useHotkeys } from 'react-hotkeys-hook';
-import {
- getCanvasBaseLayer,
- getCanvasStage,
-} from 'features/canvas/util/konvaInstanceProvider';
+import { getCanvasBaseLayer } from 'features/canvas/util/konvaInstanceProvider';
+import { systemSelector } from 'features/system/systemSelectors';
export const selector = createSelector(
- [canvasSelector, isStagingSelector],
- (canvas, isStaging) => {
+ [canvasSelector, isStagingSelector, systemSelector],
+ (canvas, isStaging, system) => {
+ const { isProcessing } = system;
const { tool } = canvas;
+
return {
tool,
isStaging,
+ isProcessing,
};
},
{
@@ -54,7 +55,7 @@ export const selector = createSelector(
const IAICanvasOutpaintingControls = () => {
const dispatch = useAppDispatch();
- const { tool, isStaging } = useAppSelector(selector);
+ const { tool, isStaging, isProcessing } = useAppSelector(selector);
const canvasBaseLayer = getCanvasBaseLayer();
useHotkeys(
@@ -87,10 +88,10 @@ const IAICanvasOutpaintingControls = () => {
handleMergeVisible();
},
{
- enabled: () => true,
+ enabled: () => !isProcessing,
preventDefault: true,
},
- [canvasBaseLayer]
+ [canvasBaseLayer, isProcessing]
);
useHotkeys(
@@ -99,10 +100,10 @@ const IAICanvasOutpaintingControls = () => {
handleSaveToGallery();
},
{
- enabled: () => true,
+ enabled: () => !isProcessing,
preventDefault: true,
},
- [canvasBaseLayer]
+ [canvasBaseLayer, isProcessing]
);
useHotkeys(
@@ -111,10 +112,10 @@ const IAICanvasOutpaintingControls = () => {
handleCopyImageToClipboard();
},
{
- enabled: () => true,
+ enabled: () => !isProcessing,
preventDefault: true,
},
- [canvasBaseLayer]
+ [canvasBaseLayer, isProcessing]
);
useHotkeys(
@@ -123,10 +124,10 @@ const IAICanvasOutpaintingControls = () => {
handleDownloadAsImage();
},
{
- enabled: () => true,
+ enabled: () => !isProcessing,
preventDefault: true,
},
- [canvasBaseLayer]
+ [canvasBaseLayer, isProcessing]
);
const handleSelectMoveTool = () => dispatch(setTool('move'));
@@ -200,24 +201,28 @@ const IAICanvasOutpaintingControls = () => {
tooltip="Merge Visible (Shift + M)"
icon={}
onClick={handleMergeVisible}
+ isDisabled={isProcessing}
/>
}
onClick={handleSaveToGallery}
+ isDisabled={isProcessing}
/>
}
onClick={handleCopyImageToClipboard}
+ isDisabled={isProcessing}
/>
}
onClick={handleDownloadAsImage}
+ isDisabled={isProcessing}
/>