feat: undo/redo discard canvas staged image

This commit is contained in:
Josh Corbett 2024-03-06 19:25:43 -07:00 committed by psychedelicious
parent 549d461107
commit ad70cdfe87

View File

@ -294,6 +294,11 @@ export const canvasSlice = createSlice({
}, },
discardStagedImage: (state) => { discardStagedImage: (state) => {
const { images, selectedImageIndex } = state.layerState.stagingArea; const { images, selectedImageIndex } = state.layerState.stagingArea;
state.pastLayerStates.push(cloneDeep(state.layerState));
if (state.pastLayerStates.length > MAX_HISTORY) {
state.pastLayerStates.shift();
}
if (!images.length) { if (!images.length) {
return; return;
@ -309,6 +314,8 @@ export const canvasSlice = createSlice({
state.shouldShowStagingImage = false; state.shouldShowStagingImage = false;
state.shouldShowStagingOutline = false; state.shouldShowStagingOutline = false;
} }
state.futureLayerStates = [];
}, },
addFillRect: (state) => { addFillRect: (state) => {
const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } = state; const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } = state;