mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
ui: gallery enhancements (#3752)
* feat(ui): salvaged gallery UI enhancements * restore boardimage functionality, load boardimages and remove some cachine optimizations in the name of data integrity * fix assets, fix load more params * jk NOW fix assets, fix load more params --------- Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local> Co-authored-by: Mary Hipp Rogers <maryhipp@gmail.com>
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
import { OffsetPaginatedResults_ImageDTO_ } from 'services/api/types';
|
||||
import { api } from '..';
|
||||
import { ApiFullTagDescription, LIST_TAG, api } from '..';
|
||||
import { paths } from '../schema';
|
||||
import { imagesApi } from './images';
|
||||
|
||||
type ListBoardImagesArg =
|
||||
paths['/api/v1/board_images/{board_id}']['get']['parameters']['path'] &
|
||||
paths['/api/v1/board_images/{board_id}']['get']['parameters']['query'];
|
||||
paths['/api/v1/board_images/{board_id}']['get']['parameters']['query'];
|
||||
|
||||
type AddImageToBoardArg =
|
||||
paths['/api/v1/board_images/']['post']['requestBody']['content']['application/json'];
|
||||
@ -25,9 +24,25 @@ export const boardImagesApi = api.injectEndpoints({
|
||||
>({
|
||||
query: ({ board_id, offset, limit }) => ({
|
||||
url: `board_images/${board_id}`,
|
||||
method: 'DELETE',
|
||||
body: { offset, limit },
|
||||
method: 'GET',
|
||||
|
||||
}),
|
||||
providesTags: (result, error, arg) => {
|
||||
// any list of boardimages
|
||||
const tags: ApiFullTagDescription[] = [{ id: 'BoardImage', type: `${arg.board_id}_${LIST_TAG}` }];
|
||||
|
||||
if (result) {
|
||||
// and individual tags for each boardimage
|
||||
tags.push(
|
||||
...result.items.map(({ board_id, image_name }) => ({
|
||||
type: 'BoardImage' as const,
|
||||
id: `${board_id}_${image_name}`,
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
return tags;
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
@ -41,23 +56,9 @@ export const boardImagesApi = api.injectEndpoints({
|
||||
body: { board_id, image_name },
|
||||
}),
|
||||
invalidatesTags: (result, error, arg) => [
|
||||
{ type: 'Board', id: arg.board_id },
|
||||
{ type: 'BoardImage' },
|
||||
{ type: 'Board', id: arg.board_id }
|
||||
],
|
||||
async onQueryStarted(
|
||||
{ image_name, ...patch },
|
||||
{ dispatch, queryFulfilled }
|
||||
) {
|
||||
const patchResult = dispatch(
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
Object.assign(draft, patch);
|
||||
})
|
||||
);
|
||||
try {
|
||||
await queryFulfilled;
|
||||
} catch {
|
||||
patchResult.undo();
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
removeImageFromBoard: build.mutation<void, RemoveImageFromBoardArg>({
|
||||
@ -67,23 +68,9 @@ export const boardImagesApi = api.injectEndpoints({
|
||||
body: { board_id, image_name },
|
||||
}),
|
||||
invalidatesTags: (result, error, arg) => [
|
||||
{ type: 'Board', id: arg.board_id },
|
||||
{ type: 'BoardImage' },
|
||||
{ type: 'Board', id: arg.board_id }
|
||||
],
|
||||
async onQueryStarted(
|
||||
{ image_name, ...patch },
|
||||
{ dispatch, queryFulfilled }
|
||||
) {
|
||||
const patchResult = dispatch(
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
Object.assign(draft, { board_id: null });
|
||||
})
|
||||
);
|
||||
try {
|
||||
await queryFulfilled;
|
||||
} catch {
|
||||
patchResult.undo();
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
Reference in New Issue
Block a user