fix(ui): reset canvas batchIds on staging area init/discard/commit

This prevents the bbox from being used inadvertantly during canvas generation
This commit is contained in:
psychedelicious 2023-09-27 17:11:07 +10:00
parent d467e138a4
commit 03e463dc89

View File

@ -186,7 +186,7 @@ export const canvasSlice = createSlice({
state.pastLayerStates.push(cloneDeep(state.layerState)); state.pastLayerStates.push(cloneDeep(state.layerState));
state.layerState = { state.layerState = {
...initialLayerState, ...cloneDeep(initialLayerState),
objects: [ objects: [
{ {
kind: 'image', kind: 'image',
@ -200,6 +200,7 @@ export const canvasSlice = createSlice({
], ],
}; };
state.futureLayerStates = []; state.futureLayerStates = [];
state.batchIds = [];
const newScale = calculateScale( const newScale = calculateScale(
stageDimensions.width, stageDimensions.width,
@ -349,11 +350,14 @@ export const canvasSlice = createSlice({
state.pastLayerStates.shift(); state.pastLayerStates.shift();
} }
state.layerState.stagingArea = { ...initialLayerState.stagingArea }; state.layerState.stagingArea = cloneDeep(
cloneDeep(initialLayerState)
).stagingArea;
state.futureLayerStates = []; state.futureLayerStates = [];
state.shouldShowStagingOutline = true; state.shouldShowStagingOutline = true;
state.shouldShowStagingOutline = true; state.shouldShowStagingImage = true;
state.batchIds = [];
}, },
addFillRect: (state) => { addFillRect: (state) => {
const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } = const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } =
@ -490,8 +494,9 @@ export const canvasSlice = createSlice({
resetCanvas: (state) => { resetCanvas: (state) => {
state.pastLayerStates.push(cloneDeep(state.layerState)); state.pastLayerStates.push(cloneDeep(state.layerState));
state.layerState = initialLayerState; state.layerState = cloneDeep(initialLayerState);
state.futureLayerStates = []; state.futureLayerStates = [];
state.batchIds = [];
}, },
canvasResized: ( canvasResized: (
state, state,
@ -656,13 +661,12 @@ export const canvasSlice = createSlice({
...imageToCommit, ...imageToCommit,
}); });
} }
state.layerState.stagingArea = { state.layerState.stagingArea = cloneDeep(initialLayerState).stagingArea;
...initialLayerState.stagingArea,
};
state.futureLayerStates = []; state.futureLayerStates = [];
state.shouldShowStagingOutline = true; state.shouldShowStagingOutline = true;
state.shouldShowStagingImage = true; state.shouldShowStagingImage = true;
state.batchIds = [];
}, },
fitBoundingBoxToStage: (state) => { fitBoundingBoxToStage: (state) => {
const { const {