Skip to content

Commit 3f58c68

Browse files
Mary Hippmaryhipp
Mary Hipp
authored andcommitted
fix tag invalidation
1 parent e50c7e5 commit 3f58c68

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/imageUploaded.ts

+24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { omit } from 'lodash-es';
1111
import { boardsApi } from 'services/api/endpoints/boards';
1212
import { imagesApi } from 'services/api/endpoints/images';
1313
import type { ImageDTO } from 'services/api/types';
14+
import { getCategories, getListImagesUrl } from 'services/api/util';
1415
const log = logger('gallery');
1516

1617
/**
@@ -59,6 +60,29 @@ export const addImageUploadedFulfilledListener = (startAppListening: AppStartLis
5960
return;
6061
}
6162

63+
if (imageUploadedClientSide.match(action)) {
64+
const categories = getCategories(imageDTO);
65+
const boardId = imageDTO.board_id ?? 'none';
66+
dispatch(
67+
imagesApi.util.invalidateTags([
68+
{
69+
type: 'ImageList',
70+
id: getListImagesUrl({
71+
board_id: boardId,
72+
categories,
73+
}),
74+
},
75+
{
76+
type: 'Board',
77+
id: boardId,
78+
},
79+
{
80+
type: 'BoardImagesTotal',
81+
id: boardId,
82+
},
83+
])
84+
);
85+
}
6286
const state = getState();
6387

6488
log.debug({ imageDTO }, 'Image uploaded');

invokeai/frontend/web/src/services/api/endpoints/images.ts

+2-28
Original file line numberDiff line numberDiff line change
@@ -318,37 +318,11 @@ export const imagesApi = api.injectEndpoints({
318318
},
319319
}),
320320
createImageUploadEntry: build.mutation<ImageUploadEntryResponse, ImageUploadEntryRequest>({
321-
query: ({ width, height }) => ({
321+
query: ({ width, height, board_id }) => ({
322322
url: buildImagesUrl(),
323323
method: 'POST',
324-
body: { width, height },
324+
body: { width, height, board_id },
325325
}),
326-
invalidatesTags: (result) => {
327-
if (!result) {
328-
// Don't add it to anything
329-
return [];
330-
}
331-
const categories = getCategories(result.image_dto);
332-
const boardId = result.image_dto.board_id ?? 'none';
333-
334-
return [
335-
{
336-
type: 'ImageList',
337-
id: getListImagesUrl({
338-
board_id: boardId,
339-
categories,
340-
}),
341-
},
342-
{
343-
type: 'Board',
344-
id: boardId,
345-
},
346-
{
347-
type: 'BoardImagesTotal',
348-
id: boardId,
349-
},
350-
];
351-
},
352326
}),
353327
deleteBoard: build.mutation<DeleteBoardResult, string>({
354328
query: (board_id) => ({ url: buildBoardsUrl(board_id), method: 'DELETE' }),

0 commit comments

Comments
 (0)