mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix missing 'none' on no-board cache updates
This commit is contained in:
parent
5396e998b3
commit
8e98085530
@ -225,7 +225,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
dispatch(
|
dispatch(
|
||||||
imagesApi.util.updateQueryData(
|
imagesApi.util.updateQueryData(
|
||||||
'listImages',
|
'listImages',
|
||||||
{ board_id, categories },
|
{ board_id: board_id ?? 'none', categories },
|
||||||
(draft) => {
|
(draft) => {
|
||||||
const oldTotal = draft.total;
|
const oldTotal = draft.total;
|
||||||
const newState = imagesAdapter.removeOne(draft, image_name);
|
const newState = imagesAdapter.removeOne(draft, image_name);
|
||||||
@ -300,7 +300,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
dispatch(
|
dispatch(
|
||||||
imagesApi.util.updateQueryData(
|
imagesApi.util.updateQueryData(
|
||||||
'listImages',
|
'listImages',
|
||||||
{ board_id: imageDTO.board_id, categories },
|
{ board_id: imageDTO.board_id ?? 'none', categories },
|
||||||
(draft) => {
|
(draft) => {
|
||||||
const oldTotal = draft.total;
|
const oldTotal = draft.total;
|
||||||
const newState = imagesAdapter.removeOne(
|
const newState = imagesAdapter.removeOne(
|
||||||
@ -315,7 +315,10 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// ELSE (it is being changed to a non-intermediate):
|
// ELSE (it is being changed to a non-intermediate):
|
||||||
const queryArgs = { board_id: imageDTO.board_id, categories };
|
const queryArgs = {
|
||||||
|
board_id: imageDTO.board_id ?? 'none',
|
||||||
|
categories,
|
||||||
|
};
|
||||||
|
|
||||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(
|
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(
|
||||||
getState()
|
getState()
|
||||||
@ -539,48 +542,30 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (imageDTO.board_id) {
|
// *remove* from [no_board|board_id]/[images|assets]
|
||||||
// *remove* from old board_id/[images|assets]
|
patches.push(
|
||||||
patches.push(
|
dispatch(
|
||||||
dispatch(
|
imagesApi.util.updateQueryData(
|
||||||
imagesApi.util.updateQueryData(
|
'listImages',
|
||||||
'listImages',
|
{
|
||||||
{
|
board_id: imageDTO.board_id ?? 'none',
|
||||||
board_id: imageDTO.board_id,
|
categories,
|
||||||
categories,
|
},
|
||||||
},
|
(draft) => {
|
||||||
(draft) => {
|
const oldTotal = draft.total;
|
||||||
const oldTotal = draft.total;
|
const newState = imagesAdapter.removeOne(
|
||||||
const newState = imagesAdapter.removeOne(
|
draft,
|
||||||
draft,
|
imageDTO.image_name
|
||||||
imageDTO.image_name
|
);
|
||||||
);
|
const delta = newState.total - oldTotal;
|
||||||
const delta = newState.total - oldTotal;
|
draft.total = draft.total + delta;
|
||||||
draft.total = draft.total + delta;
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
} else {
|
);
|
||||||
// *remove* from no_board/[images|assets]
|
|
||||||
patches.push(
|
|
||||||
dispatch(
|
|
||||||
imagesApi.util.updateQueryData(
|
|
||||||
'listImages',
|
|
||||||
{
|
|
||||||
board_id: 'none',
|
|
||||||
categories,
|
|
||||||
},
|
|
||||||
(draft) => {
|
|
||||||
imagesAdapter.removeOne(draft, imageDTO.image_name);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// $cache = board_id/[images|assets]
|
// $cache = board_id/[images|assets]
|
||||||
const queryArgs = { board_id, categories };
|
const queryArgs = { board_id: board_id ?? 'none', categories };
|
||||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(
|
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(
|
||||||
getState()
|
getState()
|
||||||
);
|
);
|
||||||
@ -676,7 +661,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
imagesApi.util.updateQueryData(
|
imagesApi.util.updateQueryData(
|
||||||
'listImages',
|
'listImages',
|
||||||
{
|
{
|
||||||
board_id: imageDTO.board_id,
|
board_id: imageDTO.board_id ?? 'none',
|
||||||
categories,
|
categories,
|
||||||
},
|
},
|
||||||
(draft) => {
|
(draft) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user