From 23f0c7035c6d1c0ef7cea987262d70c2aa918e8c Mon Sep 17 00:00:00 2001 From: mickr777 <115216705+mickr777@users.noreply.github.com> Date: Wed, 19 Jul 2023 18:54:50 +1000 Subject: [PATCH] Tweaks to Image Progress Node (#3833) * Update nodesSlice.ts * Update ProgressImageNode.tsx * remove unused code * Remove Fixed Ratio I was causing issues * fix: Progress Image Node Size --------- Co-authored-by: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> --- .../nodes/components/ProgressImageNode.tsx | 46 +++++++++++-------- .../src/features/nodes/store/nodesSlice.ts | 9 ++++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/components/ProgressImageNode.tsx b/invokeai/frontend/web/src/features/nodes/components/ProgressImageNode.tsx index faaec06e49..142e2a2990 100644 --- a/invokeai/frontend/web/src/features/nodes/components/ProgressImageNode.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/ProgressImageNode.tsx @@ -1,33 +1,46 @@ import { Flex, Image } from '@chakra-ui/react'; -import { NodeProps } from 'reactflow'; -import { InvocationValue } from '../types/types'; - -import { useAppSelector } from 'app/store/storeHooks'; +import { RootState } from 'app/store/store'; import { IAINoContentFallback } from 'common/components/IAIImageFallback'; import { memo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { NodeProps, OnResize } from 'reactflow'; +import { setProgressNodeSize } from '../store/nodesSlice'; import IAINodeHeader from './IAINode/IAINodeHeader'; import IAINodeResizer from './IAINode/IAINodeResizer'; import NodeWrapper from './NodeWrapper'; -const ProgressImageNode = (props: NodeProps) => { - const progressImage = useAppSelector((state) => state.system.progressImage); +const ProgressImageNode = (props: NodeProps) => { + const progressImage = useSelector( + (state: RootState) => state.system.progressImage + ); + const progressNodeSize = useSelector( + (state: RootState) => state.nodes.progressNodeSize + ); + const dispatch = useDispatch(); const { selected } = props; + const handleResize: OnResize = (_, newSize) => { + dispatch(setProgressNodeSize(newSize)); + }; + return ( - {progressImage ? ( @@ -42,22 +55,17 @@ const ProgressImageNode = (props: NodeProps) => { ) : ( )} - + ); }; diff --git a/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts b/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts index 833a220336..997d0493dd 100644 --- a/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts +++ b/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts @@ -35,6 +35,7 @@ export type NodesState = { shouldShowFieldTypeLegend: boolean; shouldShowMinimapPanel: boolean; editorInstance: ReactFlowInstance | undefined; + progressNodeSize: { width: number; height: number }; }; export const initialNodesState: NodesState = { @@ -47,6 +48,7 @@ export const initialNodesState: NodesState = { shouldShowFieldTypeLegend: false, shouldShowMinimapPanel: true, editorInstance: undefined, + progressNodeSize: { width: 512, height: 512 }, }; const nodesSlice = createSlice({ @@ -157,6 +159,12 @@ const nodesSlice = createSlice({ loadFileEdges: (state, action: PayloadAction) => { state.edges = action.payload; }, + setProgressNodeSize: ( + state, + action: PayloadAction<{ width: number; height: number }> + ) => { + state.progressNodeSize = action.payload; + }, }, extraReducers: (builder) => { builder.addCase(receivedOpenAPISchema.fulfilled, (state, action) => { @@ -182,6 +190,7 @@ export const { setEditorInstance, loadFileNodes, loadFileEdges, + setProgressNodeSize, } = nodesSlice.actions; export default nodesSlice.reducer;