fix(ui): reset canvas batchIds on clear/batch cancel

Closes #4889
This commit is contained in:
psychedelicious 2023-10-15 18:28:05 +11:00
parent 1c099e0abb
commit 2060ee22f2

View File

@ -30,6 +30,7 @@ import {
isCanvasMaskLine, isCanvasMaskLine,
} from './canvasTypes'; } from './canvasTypes';
import { appSocketQueueItemStatusChanged } from 'services/events/actions'; import { appSocketQueueItemStatusChanged } from 'services/events/actions';
import { queueApi } from 'services/api/endpoints/queue';
export const initialLayerState: CanvasLayerState = { export const initialLayerState: CanvasLayerState = {
objects: [], objects: [],
@ -812,6 +813,20 @@ export const canvasSlice = createSlice({
); );
} }
}); });
builder.addMatcher(
queueApi.endpoints.clearQueue.matchFulfilled,
(state) => {
state.batchIds = [];
}
);
builder.addMatcher(
queueApi.endpoints.cancelByBatchIds.matchFulfilled,
(state, action) => {
state.batchIds = state.batchIds.filter(
(id) => !action.meta.arg.originalArgs.batch_ids.includes(id)
);
}
);
}, },
}); });