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

## What type of PR is this? (check all applicable)

- [ ] Refactor
- [ ] Feature
- [x] Bug Fix
- [ ] Optimization
- [ ] Documentation Update
- [ ] Community Node Submission

## Description

This was in the original fix in #4829 but I must have removed it
accidentally.

## Related Tickets & Documents

<!--
For pull requests that relate or close an issue, please include them
below. 

For example having the text: "closes #1234" would connect the current
pull
request to issue 1234.  And when we merge the pull request, Github will
automatically close the issue.
-->

- Related Issue #
- Closes #4889

## QA Instructions, Screenshots, Recordings

- Start from a fresh canvas session (may need to let a generation finish
or reset web UI if yours is locked)
- Invoke/add to queue
- Immediately cancel current, clear queue, or clear batch (can do this
from the queue tab)
- Canvas should return to normal state

<!-- 
Please provide steps on how to test changes, any hardware or 
software specifications as well as any other pertinent information. 
-->
This commit is contained in:
blessedcoolant 2023-10-15 17:10:38 +05:30 committed by GitHub
commit 10755718b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@ import {
isCanvasMaskLine,
} from './canvasTypes';
import { appSocketQueueItemStatusChanged } from 'services/events/actions';
import { queueApi } from 'services/api/endpoints/queue';
export const initialLayerState: CanvasLayerState = {
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)
);
}
);
},
});