mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): invalidate getImageDTO caches when images are mutated
This commit is contained in:
parent
fde8fc7575
commit
280ec9d4b3
@ -93,6 +93,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
const boardId = imageDTO.board_id ?? 'none';
|
const boardId = imageDTO.board_id ?? 'none';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
{ type: 'Image', id: imageDTO.image_name },
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -124,7 +125,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
const categories = getCategories(imageDTOs[0]);
|
const categories = getCategories(imageDTOs[0]);
|
||||||
const boardId = imageDTOs[0].board_id ?? 'none';
|
const boardId = imageDTOs[0].board_id ?? 'none';
|
||||||
|
|
||||||
return [
|
const tags: ApiTagDescription[] = [
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -137,6 +138,11 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
id: boardId,
|
id: boardId,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
for (const imageDTO of imageDTOs) {
|
||||||
|
tags.push({ type: 'Image', id: imageDTO.image_name });
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -155,6 +161,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
const boardId = imageDTO.board_id ?? undefined;
|
const boardId = imageDTO.board_id ?? undefined;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
{ type: 'Image', id: imageDTO.image_name },
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -181,13 +188,12 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: { image_names: images.map((img) => img.image_name) },
|
body: { image_names: images.map((img) => img.image_name) },
|
||||||
}),
|
}),
|
||||||
invalidatesTags: (result, error, { imageDTOs: images }) => {
|
invalidatesTags: (result, error, { imageDTOs }) => {
|
||||||
// assume all images are on the same board/category
|
// assume all images are on the same board/category
|
||||||
if (images[0]) {
|
if (imageDTOs[0]) {
|
||||||
const categories = getCategories(images[0]);
|
const categories = getCategories(imageDTOs[0]);
|
||||||
const boardId = images[0].board_id ?? 'none';
|
const boardId = imageDTOs[0].board_id ?? 'none';
|
||||||
|
const tags: ApiTagDescription[] = [
|
||||||
return [
|
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -200,6 +206,10 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
id: boardId,
|
id: boardId,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
for (const imageDTO of imageDTOs) {
|
||||||
|
tags.push({ type: 'Image', id: imageDTO.image_name });
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -216,13 +226,12 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: { image_names: images.map((img) => img.image_name) },
|
body: { image_names: images.map((img) => img.image_name) },
|
||||||
}),
|
}),
|
||||||
invalidatesTags: (result, error, { imageDTOs: images }) => {
|
invalidatesTags: (result, error, { imageDTOs }) => {
|
||||||
// assume all images are on the same board/category
|
// assume all images are on the same board/category
|
||||||
if (images[0]) {
|
if (imageDTOs[0]) {
|
||||||
const categories = getCategories(images[0]);
|
const categories = getCategories(imageDTOs[0]);
|
||||||
const boardId = images[0].board_id ?? 'none';
|
const boardId = imageDTOs[0].board_id ?? 'none';
|
||||||
|
const tags: ApiTagDescription[] = [
|
||||||
return [
|
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -235,6 +244,10 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
id: boardId,
|
id: boardId,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
for (const imageDTO of imageDTOs) {
|
||||||
|
tags.push({ type: 'Image', id: imageDTO.image_name });
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -336,7 +349,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
},
|
},
|
||||||
invalidatesTags: (result, error, { board_id, imageDTO }) => {
|
invalidatesTags: (result, error, { board_id, imageDTO }) => {
|
||||||
return [
|
return [
|
||||||
// refresh the old and the new
|
{ type: 'Image', id: imageDTO.image_name },
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -367,7 +380,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
},
|
},
|
||||||
invalidatesTags: (result, error, { imageDTO }) => {
|
invalidatesTags: (result, error, { imageDTO }) => {
|
||||||
return [
|
return [
|
||||||
// refresh the old and the new
|
{ type: 'Image', id: imageDTO.image_name },
|
||||||
{
|
{
|
||||||
type: 'ImageList',
|
type: 'ImageList',
|
||||||
id: getListImagesUrl({
|
id: getListImagesUrl({
|
||||||
@ -421,7 +434,9 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
});
|
});
|
||||||
tags.push({ type: 'Board', id: imageDTOs[0].board_id ?? 'none' });
|
tags.push({ type: 'Board', id: imageDTOs[0].board_id ?? 'none' });
|
||||||
}
|
}
|
||||||
|
for (const imageDTO of imageDTOs) {
|
||||||
|
tags.push({ type: 'Image', id: imageDTO.image_name });
|
||||||
|
}
|
||||||
tags.push({ type: 'Board', id: board_id });
|
tags.push({ type: 'Board', id: board_id });
|
||||||
return tags;
|
return tags;
|
||||||
},
|
},
|
||||||
@ -467,7 +482,7 @@ export const imagesApi = api.injectEndpoints({
|
|||||||
tags.push({ type: 'Board', id: 'none' });
|
tags.push({ type: 'Board', id: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tags.push({ type: 'Image', id: image_name });
|
||||||
tags.push({ type: 'Board', id: board_id });
|
tags.push({ type: 'Board', id: board_id });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user