Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): update starred gallery rows immediately

joshistoast9589ada2c295
diff --git a/invokeai/frontend/webv2/src/features/gallery/data/queryCache.test.ts b/invokeai/frontend/webv2/src/features/gallery/data/queryCache.test.ts
index 0e8d6de507..05da5f6c83 100644
--- a/invokeai/frontend/webv2/src/features/gallery/data/queryCache.test.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/data/queryCache.test.ts
@@ -66,13 +66,14 @@ const createData = (pages: GalleryItem[][]): GalleryItemsData => {
};
};
-const getItemsKey = (boardId: string, owner: AccountScope = captureAccountScope()) =>
+const getItemsKey = (boardId: string, owner: AccountScope = captureAccountScope(), starredFirst = false) =>
galleryKeys.items(
owner,
canonicalizeGalleryItemsFilter({
boardId,
galleryView: 'images',
searchTerm: '',
+ starredFirst,
})
);
@@ -131,6 +132,22 @@ describe('Gallery item cache patches', () => {
expect(rolledBack.pages[0]?.items[1]).toBe(samePageUntouched);
});
+ it('patches star state immediately when the active list sorts starred items first', () => {
+ const client = createClient();
+ const target = createItem('target.png');
+ const key = getItemsKey('board-1', captureAccountScope(), true);
+
+ client.setQueryData(key, createData([[target]]));
+
+ patchGalleryItemCaches(client, {
+ kind: 'star',
+ result: getResult([{ kind: 'image', name: target.name }]),
+ starred: true,
+ });
+
+ expect(getData(client, key).pages[0]?.items[0]).toEqual({ ...target, starred: true });
+ });
+
it('deletes matching qualified items across pages and keeps each page total consistent', () => {
const client = createClient();
const firstTarget = createItem('shared-name', 'board-1', false, 'image');
diff --git a/invokeai/frontend/webv2/src/features/gallery/data/queryCache.ts b/invokeai/frontend/webv2/src/features/gallery/data/queryCache.ts
index 17a144e0d0..ad7075408e 100644
--- a/invokeai/frontend/webv2/src/features/gallery/data/queryCache.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/data/queryCache.ts
@@ -169,10 +169,6 @@ export const patchGalleryItemCaches = (client: QueryClient, patch: GalleryItemCa
continue;
}
- if (patch.kind === 'star' && filter.starredFirst) {
- continue;
- }
-
const after = patchItemsInfiniteData(before, filter, patch, itemKeys);
if (after === before) {