From aeb0a45eb6021e134c0a7dae65de974a90420e0f Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:59:07 +1000 Subject: [PATCH] fix(ui): layer is selected when added --- .../features/controlLayers/store/controlAdaptersReducers.ts | 5 ++++- .../src/features/controlLayers/store/ipAdaptersReducers.ts | 5 ++++- .../web/src/features/controlLayers/store/layersReducers.ts | 5 ++++- .../web/src/features/controlLayers/store/regionsReducers.ts | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/store/controlAdaptersReducers.ts b/invokeai/frontend/web/src/features/controlLayers/store/controlAdaptersReducers.ts index 0a744c6c28..5c2813c2d3 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/controlAdaptersReducers.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/controlAdaptersReducers.ts @@ -44,13 +44,16 @@ export const controlAdaptersReducers = { processorPendingBatchId: null, ...config, }); + state.selectedEntityIdentifier = { type: 'control_adapter', id }; }, prepare: (config: ControlNetConfig | T2IAdapterConfig) => ({ payload: { id: uuidv4(), config }, }), }, caRecalled: (state, action: PayloadAction<{ data: ControlAdapterData }>) => { - state.controlAdapters.push(action.payload.data); + const { data } = action.payload; + state.controlAdapters.push(data); + state.selectedEntityIdentifier = { type: 'control_adapter', id: data.id }; }, caIsEnabledToggled: (state, action: PayloadAction<{ id: string }>) => { const { id } = action.payload; diff --git a/invokeai/frontend/web/src/features/controlLayers/store/ipAdaptersReducers.ts b/invokeai/frontend/web/src/features/controlLayers/store/ipAdaptersReducers.ts index fb6ff8d987..a4e950767b 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/ipAdaptersReducers.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/ipAdaptersReducers.ts @@ -25,11 +25,14 @@ export const ipAdaptersReducers = { ...config, }; state.ipAdapters.push(layer); + state.selectedEntityIdentifier = { type: 'ip_adapter', id }; }, prepare: (config: IPAdapterConfig) => ({ payload: { id: uuidv4(), config } }), }, ipaRecalled: (state, action: PayloadAction<{ data: IPAdapterData }>) => { - state.ipAdapters.push(action.payload.data); + const { data } = action.payload; + state.ipAdapters.push(data); + state.selectedEntityIdentifier = { type: 'ip_adapter', id: data.id }; }, ipaIsEnabledToggled: (state, action: PayloadAction<{ id: string }>) => { const { id } = action.payload; diff --git a/invokeai/frontend/web/src/features/controlLayers/store/layersReducers.ts b/invokeai/frontend/web/src/features/controlLayers/store/layersReducers.ts index 6b3e58f8a2..dc06f8d188 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/layersReducers.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/layersReducers.ts @@ -38,11 +38,14 @@ export const layersReducers = { x: 0, y: 0, }); + state.selectedEntityIdentifier = { type: 'layer', id }; }, prepare: () => ({ payload: { id: uuidv4() } }), }, layerRecalled: (state, action: PayloadAction<{ data: LayerData }>) => { - state.layers.push(action.payload.data); + const { data } = action.payload; + state.layers.push(data); + state.selectedEntityIdentifier = { type: 'layer', id: data.id }; }, layerIsEnabledToggled: (state, action: PayloadAction<{ id: string }>) => { const { id } = action.payload; diff --git a/invokeai/frontend/web/src/features/controlLayers/store/regionsReducers.ts b/invokeai/frontend/web/src/features/controlLayers/store/regionsReducers.ts index 9d75e0e93f..680eb35a82 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/regionsReducers.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/regionsReducers.ts @@ -72,6 +72,7 @@ export const regionsReducers = { imageCache: null, }; state.regions.push(rg); + state.selectedEntityIdentifier = { type: 'regional_guidance', id }; }, prepare: () => ({ payload: { id: uuidv4() } }), }, @@ -89,6 +90,7 @@ export const regionsReducers = { rgRecalled: (state, action: PayloadAction<{ data: RegionalGuidanceData }>) => { const { data } = action.payload; state.regions.push(data); + state.selectedEntityIdentifier = { type: 'regional_guidance', id: data.id }; }, rgIsEnabledToggled: (state, action: PayloadAction<{ id: string }>) => { const { id } = action.payload;