mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): ensure canvas size is correctly updated when model changed
Closes #6293
This commit is contained in:
parent
1b617768cf
commit
311ba8c04b
@ -8,6 +8,7 @@ import calculateScale from 'features/canvas/util/calculateScale';
|
|||||||
import { STAGE_PADDING_PERCENTAGE } from 'features/canvas/util/constants';
|
import { STAGE_PADDING_PERCENTAGE } from 'features/canvas/util/constants';
|
||||||
import floorCoordinates from 'features/canvas/util/floorCoordinates';
|
import floorCoordinates from 'features/canvas/util/floorCoordinates';
|
||||||
import getScaledBoundingBoxDimensions from 'features/canvas/util/getScaledBoundingBoxDimensions';
|
import getScaledBoundingBoxDimensions from 'features/canvas/util/getScaledBoundingBoxDimensions';
|
||||||
|
import { calculateNewSize } from 'features/parameters/components/ImageSize/calculateNewSize';
|
||||||
import { initialAspectRatioState } from 'features/parameters/components/ImageSize/constants';
|
import { initialAspectRatioState } from 'features/parameters/components/ImageSize/constants';
|
||||||
import type { AspectRatioState } from 'features/parameters/components/ImageSize/types';
|
import type { AspectRatioState } from 'features/parameters/components/ImageSize/types';
|
||||||
import { modelChanged } from 'features/parameters/store/generationSlice';
|
import { modelChanged } from 'features/parameters/store/generationSlice';
|
||||||
@ -588,8 +589,9 @@ export const canvasSlice = createSlice({
|
|||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(modelChanged, (state, action) => {
|
builder.addCase(modelChanged, (state, action) => {
|
||||||
if (action.meta.previousModel?.base === action.payload?.base) {
|
const newModel = action.payload;
|
||||||
// The base model hasn't changed, we don't need to optimize the size
|
if (!newModel || action.meta.previousModel?.base === newModel.base) {
|
||||||
|
// Model was cleared or the base didn't change
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const optimalDimension = getOptimalDimension(action.payload);
|
const optimalDimension = getOptimalDimension(action.payload);
|
||||||
@ -597,14 +599,8 @@ export const canvasSlice = createSlice({
|
|||||||
if (getIsSizeOptimal(width, height, optimalDimension)) {
|
if (getIsSizeOptimal(width, height, optimalDimension)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setBoundingBoxDimensionsReducer(
|
const newSize = calculateNewSize(state.aspectRatio.value, optimalDimension * optimalDimension);
|
||||||
state,
|
setBoundingBoxDimensionsReducer(state, newSize, optimalDimension);
|
||||||
{
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
},
|
|
||||||
optimalDimension
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.addCase(socketQueueItemStatusChanged, (state, action) => {
|
builder.addCase(socketQueueItemStatusChanged, (state, action) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user