Skip to content

Commit 03c21d1

Browse files
fix(ui): gallery not updating when saving staging area image
1 parent 752e8db commit 03c21d1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

invokeai/frontend/web/src/features/gallery/hooks/useRangeBasedImageFetching.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useAppStore } from 'app/store/storeHooks';
2-
import { useCallback } from 'react';
2+
import { useCallback, useEffect, useRef } from 'react';
33
import type { ListRange } from 'react-virtuoso';
44
import { imagesApi, useGetImageDTOsByNamesMutation } from 'services/api/endpoints/images';
55
import { useThrottledCallback } from 'use-debounce';
@@ -53,6 +53,7 @@ export const useRangeBasedImageFetching = ({
5353
}: UseRangeBasedImageFetchingArgs): UseRangeBasedImageFetchingReturn => {
5454
const store = useAppStore();
5555
const [getImageDTOsByNames] = useGetImageDTOsByNamesMutation();
56+
const lastRangeRef = useRef<ListRange | null>(null);
5657

5758
const fetchImages = useCallback(
5859
(visibleRange: ListRange) => {
@@ -65,6 +66,7 @@ export const useRangeBasedImageFetching = ({
6566
return;
6667
}
6768
getImageDTOsByNames({ image_names: uncachedNames });
69+
lastRangeRef.current = visibleRange;
6870
},
6971
[enabled, getImageDTOsByNames, imageNames, store]
7072
);
@@ -78,6 +80,13 @@ export const useRangeBasedImageFetching = ({
7880
[throttledFetchImages]
7981
);
8082

83+
useEffect(() => {
84+
if (!lastRangeRef.current) {
85+
return;
86+
}
87+
throttledFetchImages(lastRangeRef.current);
88+
}, [imageNames, throttledFetchImages]);
89+
8190
return {
8291
onRangeChanged,
8392
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ export const imagesApi = api.injectEndpoints({
263263
},
264264
};
265265
},
266-
267266
invalidatesTags: (result) => {
268267
if (!result || result.is_intermediate) {
269268
// Don't add it to anything
@@ -276,6 +275,7 @@ export const imagesApi = api.injectEndpoints({
276275
...getTagsToInvalidateForBoardAffectingMutation([boardId]),
277276
'ImageCollectionCounts',
278277
{ type: 'ImageCollection', id: LIST_TAG },
278+
'ImageNameList',
279279
];
280280
},
281281
}),

0 commit comments

Comments
 (0)