mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
chore(ui): format
Lots of changed bc the line length is now 120. May as well do it now.
This commit is contained in:
@ -1,9 +1,5 @@
|
||||
import type { paths } from 'services/api/schema';
|
||||
import type {
|
||||
AppConfig,
|
||||
AppDependencyVersions,
|
||||
AppVersion,
|
||||
} from 'services/api/types';
|
||||
import type { AppConfig, AppDependencyVersions, AppVersion } from 'services/api/types';
|
||||
|
||||
import { api } from '..';
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
import {
|
||||
ASSETS_CATEGORIES,
|
||||
IMAGE_CATEGORIES,
|
||||
} from 'features/gallery/store/types';
|
||||
import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types';
|
||||
import type {
|
||||
BoardDTO,
|
||||
ListBoardsArg,
|
||||
@ -23,10 +20,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
query: (arg) => ({ url: 'boards/', params: arg }),
|
||||
providesTags: (result) => {
|
||||
// any list of boards
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'Board', id: LIST_TAG },
|
||||
'FetchOnReconnect',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'Board', id: LIST_TAG }, 'FetchOnReconnect'];
|
||||
|
||||
if (result) {
|
||||
// and individual tags for each board
|
||||
@ -49,10 +43,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
}),
|
||||
providesTags: (result) => {
|
||||
// any list of boards
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'Board', id: LIST_TAG },
|
||||
'FetchOnReconnect',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'Board', id: LIST_TAG }, 'FetchOnReconnect'];
|
||||
|
||||
if (result) {
|
||||
// and individual tags for each board
|
||||
@ -72,10 +63,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
query: (board_id) => ({
|
||||
url: `boards/${board_id}/image_names`,
|
||||
}),
|
||||
providesTags: (result, error, arg) => [
|
||||
{ type: 'ImageNameList', id: arg },
|
||||
'FetchOnReconnect',
|
||||
],
|
||||
providesTags: (result, error, arg) => [{ type: 'ImageNameList', id: arg }, 'FetchOnReconnect'],
|
||||
keepUnusedDataFor: 0,
|
||||
}),
|
||||
|
||||
@ -90,10 +78,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
}),
|
||||
method: 'GET',
|
||||
}),
|
||||
providesTags: (result, error, arg) => [
|
||||
{ type: 'BoardImagesTotal', id: arg ?? 'none' },
|
||||
'FetchOnReconnect',
|
||||
],
|
||||
providesTags: (result, error, arg) => [{ type: 'BoardImagesTotal', id: arg ?? 'none' }, 'FetchOnReconnect'],
|
||||
transformResponse: (response: OffsetPaginatedResults_ImageDTO_) => {
|
||||
return { total: response.total };
|
||||
},
|
||||
@ -110,10 +95,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
}),
|
||||
method: 'GET',
|
||||
}),
|
||||
providesTags: (result, error, arg) => [
|
||||
{ type: 'BoardAssetsTotal', id: arg ?? 'none' },
|
||||
'FetchOnReconnect',
|
||||
],
|
||||
providesTags: (result, error, arg) => [{ type: 'BoardAssetsTotal', id: arg ?? 'none' }, 'FetchOnReconnect'],
|
||||
transformResponse: (response: OffsetPaginatedResults_ImageDTO_) => {
|
||||
return { total: response.total };
|
||||
},
|
||||
@ -138,9 +120,7 @@ export const boardsApi = api.injectEndpoints({
|
||||
method: 'PATCH',
|
||||
body: changes,
|
||||
}),
|
||||
invalidatesTags: (result, error, arg) => [
|
||||
{ type: 'Board', id: arg.board_id },
|
||||
],
|
||||
invalidatesTags: (result, error, arg) => [{ type: 'Board', id: arg.board_id }],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
@ -2,11 +2,7 @@ import type { EntityState, Update } from '@reduxjs/toolkit';
|
||||
import type { PatchCollection } from '@reduxjs/toolkit/dist/query/core/buildThunks';
|
||||
import { logger } from 'app/logging/logger';
|
||||
import type { BoardId } from 'features/gallery/store/types';
|
||||
import {
|
||||
ASSETS_CATEGORIES,
|
||||
IMAGE_CATEGORIES,
|
||||
IMAGE_LIMIT,
|
||||
} from 'features/gallery/store/types';
|
||||
import { ASSETS_CATEGORIES, IMAGE_CATEGORIES, IMAGE_LIMIT } from 'features/gallery/store/types';
|
||||
import type { CoreMetadata } from 'features/nodes/types/metadata';
|
||||
import { zCoreMetadata } from 'features/nodes/types/metadata';
|
||||
import { addToast } from 'features/system/store/systemSlice';
|
||||
@ -84,13 +80,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
// update the `getImageDTO` cache for each image
|
||||
imagesSelectors.selectAll(data).forEach((imageDTO) => {
|
||||
dispatch(
|
||||
imagesApi.util.upsertQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
imageDTO
|
||||
)
|
||||
);
|
||||
dispatch(imagesApi.util.upsertQueryData('getImageDTO', imageDTO.image_name, imageDTO));
|
||||
});
|
||||
} catch {
|
||||
// no-op
|
||||
@ -109,16 +99,12 @@ export const imagesApi = api.injectEndpoints({
|
||||
}),
|
||||
getImageDTO: build.query<ImageDTO, string>({
|
||||
query: (image_name) => ({ url: `images/i/${image_name}` }),
|
||||
providesTags: (result, error, image_name) => [
|
||||
{ type: 'Image', id: image_name },
|
||||
],
|
||||
providesTags: (result, error, image_name) => [{ type: 'Image', id: image_name }],
|
||||
keepUnusedDataFor: 86400, // 24 hours
|
||||
}),
|
||||
getImageMetadata: build.query<CoreMetadata | undefined, string>({
|
||||
query: (image_name) => ({ url: `images/i/${image_name}/metadata` }),
|
||||
providesTags: (result, error, image_name) => [
|
||||
{ type: 'ImageMetadata', id: image_name },
|
||||
],
|
||||
providesTags: (result, error, image_name) => [{ type: 'ImageMetadata', id: image_name }],
|
||||
transformResponse: (
|
||||
response: paths['/api/v1/images/i/{image_name}/metadata']['get']['responses']['200']['content']['application/json']
|
||||
) => {
|
||||
@ -139,9 +125,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
string
|
||||
>({
|
||||
query: (image_name) => ({ url: `images/i/${image_name}/workflow` }),
|
||||
providesTags: (result, error, image_name) => [
|
||||
{ type: 'ImageWorkflow', id: image_name },
|
||||
],
|
||||
providesTags: (result, error, image_name) => [{ type: 'ImageWorkflow', id: image_name }],
|
||||
keepUnusedDataFor: 86400, // 24 hours
|
||||
}),
|
||||
deleteImage: build.mutation<void, ImageDTO>({
|
||||
@ -197,10 +181,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
}
|
||||
},
|
||||
}),
|
||||
deleteImages: build.mutation<
|
||||
components['schemas']['DeleteImagesFromListResult'],
|
||||
{ imageDTOs: ImageDTO[] }
|
||||
>({
|
||||
deleteImages: build.mutation<components['schemas']['DeleteImagesFromListResult'], { imageDTOs: ImageDTO[] }>({
|
||||
query: ({ imageDTOs }) => {
|
||||
const image_names = imageDTOs.map((imageDTO) => imageDTO.image_name);
|
||||
return {
|
||||
@ -248,18 +229,12 @@ export const imagesApi = api.injectEndpoints({
|
||||
};
|
||||
// remove all deleted images from their boards
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArg,
|
||||
(draft) => {
|
||||
imagesAdapter.removeOne(draft, image_name);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArg, (draft) => {
|
||||
imagesAdapter.removeOne(draft, image_name);
|
||||
})
|
||||
);
|
||||
|
||||
const isAsset = ASSETS_CATEGORIES.includes(
|
||||
imageDTO.image_category
|
||||
);
|
||||
const isAsset = ASSETS_CATEGORIES.includes(imageDTO.image_category);
|
||||
|
||||
// decrement the image board's total
|
||||
dispatch(
|
||||
@ -281,19 +256,13 @@ export const imagesApi = api.injectEndpoints({
|
||||
/**
|
||||
* Change an image's `is_intermediate` property.
|
||||
*/
|
||||
changeImageIsIntermediate: build.mutation<
|
||||
ImageDTO,
|
||||
{ imageDTO: ImageDTO; is_intermediate: boolean }
|
||||
>({
|
||||
changeImageIsIntermediate: build.mutation<ImageDTO, { imageDTO: ImageDTO; is_intermediate: boolean }>({
|
||||
query: ({ imageDTO, is_intermediate }) => ({
|
||||
url: `images/i/${imageDTO.image_name}`,
|
||||
method: 'PATCH',
|
||||
body: { is_intermediate },
|
||||
}),
|
||||
async onQueryStarted(
|
||||
{ imageDTO, is_intermediate },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ imageDTO, is_intermediate }, { dispatch, queryFulfilled, getState }) {
|
||||
/**
|
||||
* Cache changes for `changeImageIsIntermediate`:
|
||||
* - *update* getImageDTO
|
||||
@ -313,13 +282,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
// *update* getImageDTO
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
(draft) => {
|
||||
Object.assign(draft, { is_intermediate });
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
|
||||
Object.assign(draft, { is_intermediate });
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@ -375,16 +340,11 @@ export const imagesApi = api.injectEndpoints({
|
||||
categories,
|
||||
};
|
||||
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(imageDTO.board_id ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(imageDTO.board_id ?? 'none')(getState());
|
||||
|
||||
// IF it eligible for insertion into existing $cache
|
||||
// "eligible" means either:
|
||||
@ -392,26 +352,17 @@ export const imagesApi = api.injectEndpoints({
|
||||
// OR
|
||||
// - The image's `created_at` is within the range of the cached images
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange = getIsImageInDateRange(
|
||||
currentCache.data,
|
||||
imageDTO
|
||||
);
|
||||
const isInDateRange = getIsImageInDateRange(currentCache.data, imageDTO);
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// *upsert* to $cache
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, imageDTO);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, imageDTO);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -427,19 +378,13 @@ export const imagesApi = api.injectEndpoints({
|
||||
/**
|
||||
* Change an image's `session_id` association.
|
||||
*/
|
||||
changeImageSessionId: build.mutation<
|
||||
ImageDTO,
|
||||
{ imageDTO: ImageDTO; session_id: string }
|
||||
>({
|
||||
changeImageSessionId: build.mutation<ImageDTO, { imageDTO: ImageDTO; session_id: string }>({
|
||||
query: ({ imageDTO, session_id }) => ({
|
||||
url: `images/i/${imageDTO.image_name}`,
|
||||
method: 'PATCH',
|
||||
body: { session_id },
|
||||
}),
|
||||
async onQueryStarted(
|
||||
{ imageDTO, session_id },
|
||||
{ dispatch, queryFulfilled }
|
||||
) {
|
||||
async onQueryStarted({ imageDTO, session_id }, { dispatch, queryFulfilled }) {
|
||||
/**
|
||||
* Cache changes for `changeImageSessionId`:
|
||||
* - *update* getImageDTO
|
||||
@ -451,13 +396,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
// *update* getImageDTO
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
(draft) => {
|
||||
Object.assign(draft, { session_id });
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
|
||||
Object.assign(draft, { session_id });
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@ -502,10 +443,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
}
|
||||
return [];
|
||||
},
|
||||
async onQueryStarted(
|
||||
{ imageDTOs },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ imageDTOs }, { dispatch, queryFulfilled, getState }) {
|
||||
try {
|
||||
/**
|
||||
* Cache changes for pinImages:
|
||||
@ -514,9 +452,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
*/
|
||||
|
||||
const { data } = await queryFulfilled;
|
||||
const updatedImages = imageDTOs.filter((i) =>
|
||||
data.updated_image_names.includes(i.image_name)
|
||||
);
|
||||
const updatedImages = imageDTOs.filter((i) => data.updated_image_names.includes(i.image_name));
|
||||
|
||||
if (!updatedImages[0]) {
|
||||
return;
|
||||
@ -529,13 +465,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
updatedImages.forEach((imageDTO) => {
|
||||
const { image_name } = imageDTO;
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
image_name,
|
||||
(draft) => {
|
||||
draft.starred = true;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
draft.starred = true;
|
||||
})
|
||||
);
|
||||
|
||||
const queryArgs = {
|
||||
@ -543,39 +475,26 @@ export const imagesApi = api.injectEndpoints({
|
||||
categories,
|
||||
};
|
||||
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
boardId ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
boardId ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(boardId ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(boardId ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange =
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT
|
||||
? getIsImageInDateRange(currentCache.data, imageDTO)
|
||||
: true;
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT ? getIsImageInDateRange(currentCache.data, imageDTO) : true;
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// *upsert* to $cache
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
starred: true,
|
||||
});
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
starred: true,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -617,10 +536,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
}
|
||||
return [];
|
||||
},
|
||||
async onQueryStarted(
|
||||
{ imageDTOs },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ imageDTOs }, { dispatch, queryFulfilled, getState }) {
|
||||
try {
|
||||
/**
|
||||
* Cache changes for unstarImages:
|
||||
@ -629,9 +545,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
*/
|
||||
|
||||
const { data } = await queryFulfilled;
|
||||
const updatedImages = imageDTOs.filter((i) =>
|
||||
data.updated_image_names.includes(i.image_name)
|
||||
);
|
||||
const updatedImages = imageDTOs.filter((i) => data.updated_image_names.includes(i.image_name));
|
||||
|
||||
if (!updatedImages[0]) {
|
||||
return;
|
||||
@ -643,13 +557,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
updatedImages.forEach((imageDTO) => {
|
||||
const { image_name } = imageDTO;
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
image_name,
|
||||
(draft) => {
|
||||
draft.starred = false;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
draft.starred = false;
|
||||
})
|
||||
);
|
||||
|
||||
const queryArgs = {
|
||||
@ -657,39 +567,26 @@ export const imagesApi = api.injectEndpoints({
|
||||
categories,
|
||||
};
|
||||
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
boardId ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
boardId ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(boardId ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(boardId ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange =
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT
|
||||
? getIsImageInDateRange(currentCache.data, imageDTO)
|
||||
: true;
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT ? getIsImageInDateRange(currentCache.data, imageDTO) : true;
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// *upsert* to $cache
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
starred: false,
|
||||
});
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
starred: false,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -710,14 +607,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
crop_visible?: boolean;
|
||||
}
|
||||
>({
|
||||
query: ({
|
||||
file,
|
||||
image_category,
|
||||
is_intermediate,
|
||||
session_id,
|
||||
board_id,
|
||||
crop_visible,
|
||||
}) => {
|
||||
query: ({ file, image_category, is_intermediate, session_id, board_id, crop_visible }) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return {
|
||||
@ -753,13 +643,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
}
|
||||
|
||||
// *add* to `getImageDTO`
|
||||
dispatch(
|
||||
imagesApi.util.upsertQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
imageDTO
|
||||
)
|
||||
);
|
||||
dispatch(imagesApi.util.upsertQueryData('getImageDTO', imageDTO.image_name, imageDTO));
|
||||
|
||||
const categories = getCategories(imageDTO);
|
||||
|
||||
@ -779,13 +663,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
// increment new board's total
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
'getBoardAssetsTotal',
|
||||
imageDTO.board_id ?? 'none',
|
||||
(draft) => {
|
||||
draft.total += 1;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData('getBoardAssetsTotal', imageDTO.board_id ?? 'none', (draft) => {
|
||||
draft.total += 1;
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
// query failed, no action needed
|
||||
@ -834,36 +714,24 @@ export const imagesApi = api.injectEndpoints({
|
||||
// update getImageDTO caches
|
||||
deleted_board_images.forEach((image_id) => {
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
image_id,
|
||||
(draft) => {
|
||||
draft.board_id = undefined;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_id, (draft) => {
|
||||
draft.board_id = undefined;
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// set the board's asset total to 0 (feels unnecessary since we are deleting it?)
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
'getBoardAssetsTotal',
|
||||
board_id,
|
||||
(draft) => {
|
||||
draft.total = 0;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData('getBoardAssetsTotal', board_id, (draft) => {
|
||||
draft.total = 0;
|
||||
})
|
||||
);
|
||||
|
||||
// set the board's images total to 0 (feels unnecessary since we are deleting it?)
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
'getBoardImagesTotal',
|
||||
board_id,
|
||||
(draft) => {
|
||||
draft.total = 0;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData('getBoardImagesTotal', board_id, (draft) => {
|
||||
draft.total = 0;
|
||||
})
|
||||
);
|
||||
|
||||
// update 'All Images' & 'All Assets' caches
|
||||
@ -876,22 +744,16 @@ export const imagesApi = api.injectEndpoints({
|
||||
},
|
||||
];
|
||||
|
||||
const updates: Update<ImageDTO, string>[] = deleted_board_images.map(
|
||||
(image_name) => ({
|
||||
id: image_name,
|
||||
changes: { board_id: undefined },
|
||||
})
|
||||
);
|
||||
const updates: Update<ImageDTO, string>[] = deleted_board_images.map((image_name) => ({
|
||||
id: image_name,
|
||||
changes: { board_id: undefined },
|
||||
}));
|
||||
|
||||
queryArgsToUpdate.forEach((queryArgs) => {
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.updateMany(draft, updates);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.updateMany(draft, updates);
|
||||
})
|
||||
);
|
||||
});
|
||||
} catch {
|
||||
@ -950,46 +812,31 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
queryArgsToUpdate.forEach((queryArgs) => {
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.removeMany(draft, deleted_images);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.removeMany(draft, deleted_images);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// set the board's asset total to 0 (feels unnecessary since we are deleting it?)
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
'getBoardAssetsTotal',
|
||||
board_id,
|
||||
(draft) => {
|
||||
draft.total = 0;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData('getBoardAssetsTotal', board_id, (draft) => {
|
||||
draft.total = 0;
|
||||
})
|
||||
);
|
||||
|
||||
// set the board's images total to 0 (feels unnecessary since we are deleting it?)
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
'getBoardImagesTotal',
|
||||
board_id,
|
||||
(draft) => {
|
||||
draft.total = 0;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData('getBoardImagesTotal', board_id, (draft) => {
|
||||
draft.total = 0;
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
//no-op
|
||||
}
|
||||
},
|
||||
}),
|
||||
addImageToBoard: build.mutation<
|
||||
void,
|
||||
{ board_id: BoardId; imageDTO: ImageDTO }
|
||||
>({
|
||||
addImageToBoard: build.mutation<void, { board_id: BoardId; imageDTO: ImageDTO }>({
|
||||
query: ({ board_id, imageDTO }) => {
|
||||
const { image_name } = imageDTO;
|
||||
return {
|
||||
@ -1002,10 +849,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
// refresh the board itself
|
||||
{ type: 'Board', id: board_id },
|
||||
],
|
||||
async onQueryStarted(
|
||||
{ board_id, imageDTO },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ board_id, imageDTO }, { dispatch, queryFulfilled, getState }) {
|
||||
/**
|
||||
* Cache changes for `addImageToBoard`:
|
||||
* - *update* getImageDTO
|
||||
@ -1027,13 +871,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
// *update* getImageDTO
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
(draft) => {
|
||||
draft.board_id = board_id;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
|
||||
draft.board_id = board_id;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@ -1082,8 +922,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
// $cache = board_id/[images|assets]
|
||||
const queryArgs = { board_id: board_id ?? 'none', categories };
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
// IF it eligible for insertion into existing $cache
|
||||
// "eligible" means either:
|
||||
@ -1092,33 +931,20 @@ export const imagesApi = api.injectEndpoints({
|
||||
// - The image's `created_at` is within the range of the cached images
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(imageDTO.board_id ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(imageDTO.board_id ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange = getIsImageInDateRange(
|
||||
currentCache.data,
|
||||
imageDTO
|
||||
);
|
||||
const isInDateRange = getIsImageInDateRange(currentCache.data, imageDTO);
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// THEN *add* to $cache
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.addOne(draft, imageDTO);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.addOne(draft, imageDTO);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1147,10 +973,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
{ type: 'Board', id: board_id ?? 'none' },
|
||||
];
|
||||
},
|
||||
async onQueryStarted(
|
||||
{ imageDTO },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ imageDTO }, { dispatch, queryFulfilled, getState }) {
|
||||
/**
|
||||
* Cache changes for removeImageFromBoard:
|
||||
* - *update* getImageDTO
|
||||
@ -1169,13 +992,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
// *update* getImageDTO
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
imageDTO.image_name,
|
||||
(draft) => {
|
||||
draft.board_id = undefined;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
|
||||
draft.board_id = undefined;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@ -1211,20 +1030,15 @@ export const imagesApi = api.injectEndpoints({
|
||||
// increment new board's total (no board)
|
||||
patches.push(
|
||||
dispatch(
|
||||
boardsApi.util.updateQueryData(
|
||||
isAsset ? 'getBoardAssetsTotal' : 'getBoardImagesTotal',
|
||||
'none',
|
||||
(draft) => {
|
||||
draft.total += 1;
|
||||
}
|
||||
)
|
||||
boardsApi.util.updateQueryData(isAsset ? 'getBoardAssetsTotal' : 'getBoardImagesTotal', 'none', (draft) => {
|
||||
draft.total += 1;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
// $cache = no_board/[images|assets]
|
||||
const queryArgs = { board_id: 'none', categories };
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
// IF it eligible for insertion into existing $cache
|
||||
// "eligible" means either:
|
||||
@ -1233,33 +1047,20 @@ export const imagesApi = api.injectEndpoints({
|
||||
// - The image's `created_at` is within the range of the cached images
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(imageDTO.board_id ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(imageDTO.board_id ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange = getIsImageInDateRange(
|
||||
currentCache.data,
|
||||
imageDTO
|
||||
);
|
||||
const isInDateRange = getIsImageInDateRange(currentCache.data, imageDTO);
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// THEN *upsert* to $cache
|
||||
patches.push(
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, imageDTO);
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, imageDTO);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1292,10 +1093,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
{ type: 'Board', id: board_id ?? 'none' },
|
||||
];
|
||||
},
|
||||
async onQueryStarted(
|
||||
{ board_id: new_board_id, imageDTOs },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ board_id: new_board_id, imageDTOs }, { dispatch, queryFulfilled, getState }) {
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
const { added_image_names } = data;
|
||||
@ -1311,14 +1109,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
added_image_names.forEach((image_name) => {
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
image_name,
|
||||
(draft) => {
|
||||
draft.board_id =
|
||||
new_board_id === 'none' ? undefined : new_board_id;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
draft.board_id = new_board_id === 'none' ? undefined : new_board_id;
|
||||
})
|
||||
);
|
||||
|
||||
const imageDTO = imageDTOs.find((i) => i.image_name === image_name);
|
||||
@ -1369,39 +1162,26 @@ export const imagesApi = api.injectEndpoints({
|
||||
categories,
|
||||
};
|
||||
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
new_board_id ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
new_board_id ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(new_board_id ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(new_board_id ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange =
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT
|
||||
? getIsImageInDateRange(currentCache.data, imageDTO)
|
||||
: true;
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT ? getIsImageInDateRange(currentCache.data, imageDTO) : true;
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// *upsert* to $cache
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
board_id: new_board_id,
|
||||
});
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
board_id: new_board_id,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -1428,9 +1208,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
const tags: ApiTagDescription[] = [];
|
||||
|
||||
result?.removed_image_names.forEach((image_name) => {
|
||||
const board_id = imageDTOs.find(
|
||||
(i) => i.image_name === image_name
|
||||
)?.board_id;
|
||||
const board_id = imageDTOs.find((i) => i.image_name === image_name)?.board_id;
|
||||
|
||||
if (!board_id || touchedBoardIds.includes(board_id)) {
|
||||
return;
|
||||
@ -1441,10 +1219,7 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
return tags;
|
||||
},
|
||||
async onQueryStarted(
|
||||
{ imageDTOs },
|
||||
{ dispatch, queryFulfilled, getState }
|
||||
) {
|
||||
async onQueryStarted({ imageDTOs }, { dispatch, queryFulfilled, getState }) {
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
const { removed_image_names } = data;
|
||||
@ -1460,13 +1235,9 @@ export const imagesApi = api.injectEndpoints({
|
||||
|
||||
removed_image_names.forEach((image_name) => {
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'getImageDTO',
|
||||
image_name,
|
||||
(draft) => {
|
||||
draft.board_id = undefined;
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('getImageDTO', image_name, (draft) => {
|
||||
draft.board_id = undefined;
|
||||
})
|
||||
);
|
||||
|
||||
const imageDTO = imageDTOs.find((i) => i.image_name === image_name);
|
||||
@ -1517,39 +1288,26 @@ export const imagesApi = api.injectEndpoints({
|
||||
categories,
|
||||
};
|
||||
|
||||
const currentCache =
|
||||
imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
const currentCache = imagesApi.endpoints.listImages.select(queryArgs)(getState());
|
||||
|
||||
const { data } = IMAGE_CATEGORIES.includes(imageDTO.image_category)
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(
|
||||
imageDTO.board_id ?? 'none'
|
||||
)(getState());
|
||||
? boardsApi.endpoints.getBoardImagesTotal.select(imageDTO.board_id ?? 'none')(getState())
|
||||
: boardsApi.endpoints.getBoardAssetsTotal.select(imageDTO.board_id ?? 'none')(getState());
|
||||
|
||||
const isCacheFullyPopulated =
|
||||
currentCache.data &&
|
||||
currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
const isCacheFullyPopulated = currentCache.data && currentCache.data.ids.length >= (data?.total ?? 0);
|
||||
|
||||
const isInDateRange =
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT
|
||||
? getIsImageInDateRange(currentCache.data, imageDTO)
|
||||
: true;
|
||||
(data?.total ?? 0) >= IMAGE_LIMIT ? getIsImageInDateRange(currentCache.data, imageDTO) : true;
|
||||
|
||||
if (isCacheFullyPopulated || isInDateRange) {
|
||||
// *upsert* to $cache
|
||||
dispatch(
|
||||
imagesApi.util.updateQueryData(
|
||||
'listImages',
|
||||
queryArgs,
|
||||
(draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
board_id: 'none',
|
||||
});
|
||||
}
|
||||
)
|
||||
imagesApi.util.updateQueryData('listImages', queryArgs, (draft) => {
|
||||
imagesAdapter.upsertOne(draft, {
|
||||
...imageDTO,
|
||||
board_id: 'none',
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -28,9 +28,7 @@ export type DiffusersModelConfigEntity = DiffusersModelConfig & { id: string };
|
||||
export type CheckpointModelConfigEntity = CheckpointModelConfig & {
|
||||
id: string;
|
||||
};
|
||||
export type MainModelConfigEntity =
|
||||
| DiffusersModelConfigEntity
|
||||
| CheckpointModelConfigEntity;
|
||||
export type MainModelConfigEntity = DiffusersModelConfigEntity | CheckpointModelConfigEntity;
|
||||
|
||||
export type LoRAModelConfigEntity = LoRAModelConfig & { id: string };
|
||||
|
||||
@ -118,11 +116,9 @@ type AddMainModelArg = {
|
||||
body: MainModelConfig;
|
||||
};
|
||||
|
||||
type AddMainModelResponse =
|
||||
paths['/api/v1/models/add']['post']['responses']['201']['content']['application/json'];
|
||||
type AddMainModelResponse = paths['/api/v1/models/add']['post']['responses']['201']['content']['application/json'];
|
||||
|
||||
type SyncModelsResponse =
|
||||
paths['/api/v1/models/sync']['post']['responses']['201']['content']['application/json'];
|
||||
type SyncModelsResponse = paths['/api/v1/models/sync']['post']['responses']['201']['content']['application/json'];
|
||||
|
||||
export type SearchFolderResponse =
|
||||
paths['/api/v1/models/search']['get']['responses']['200']['content']['application/json'];
|
||||
@ -135,59 +131,42 @@ type SearchFolderArg = operations['search_for_models']['parameters']['query'];
|
||||
export const mainModelsAdapter = createEntityAdapter<MainModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const mainModelsAdapterSelectors = mainModelsAdapter.getSelectors(
|
||||
undefined,
|
||||
getSelectorsOptions
|
||||
);
|
||||
export const mainModelsAdapterSelectors = mainModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const loraModelsAdapter = createEntityAdapter<LoRAModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const loraModelsAdapterSelectors = loraModelsAdapter.getSelectors(
|
||||
export const loraModelsAdapterSelectors = loraModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const controlNetModelsAdapter = createEntityAdapter<ControlNetModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const controlNetModelsAdapterSelectors = controlNetModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const ipAdapterModelsAdapter = createEntityAdapter<IPAdapterModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const ipAdapterModelsAdapterSelectors = ipAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const t2iAdapterModelsAdapter = createEntityAdapter<T2IAdapterModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const t2iAdapterModelsAdapterSelectors = t2iAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const textualInversionModelsAdapter = createEntityAdapter<TextualInversionModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const textualInversionModelsAdapterSelectors = textualInversionModelsAdapter.getSelectors(
|
||||
undefined,
|
||||
getSelectorsOptions
|
||||
);
|
||||
export const controlNetModelsAdapter =
|
||||
createEntityAdapter<ControlNetModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const controlNetModelsAdapterSelectors =
|
||||
controlNetModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const ipAdapterModelsAdapter =
|
||||
createEntityAdapter<IPAdapterModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const ipAdapterModelsAdapterSelectors =
|
||||
ipAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const t2iAdapterModelsAdapter =
|
||||
createEntityAdapter<T2IAdapterModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const t2iAdapterModelsAdapterSelectors =
|
||||
t2iAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const textualInversionModelsAdapter =
|
||||
createEntityAdapter<TextualInversionModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const textualInversionModelsAdapterSelectors =
|
||||
textualInversionModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
export const vaeModelsAdapter = createEntityAdapter<VaeModelConfigEntity>({
|
||||
sortComparer: (a, b) => a.model_name.localeCompare(b.model_name),
|
||||
});
|
||||
export const vaeModelsAdapterSelectors = vaeModelsAdapter.getSelectors(
|
||||
undefined,
|
||||
getSelectorsOptions
|
||||
);
|
||||
export const vaeModelsAdapterSelectors = vaeModelsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
|
||||
export const getModelId = ({
|
||||
base_model,
|
||||
model_type,
|
||||
model_name,
|
||||
}: Pick<AnyModelConfig, 'base_model' | 'model_name' | 'model_type'>) =>
|
||||
`${base_model}/${model_type}/${model_name}`;
|
||||
}: Pick<AnyModelConfig, 'base_model' | 'model_name' | 'model_type'>) => `${base_model}/${model_type}/${model_name}`;
|
||||
|
||||
const createModelEntities = <T extends AnyModelConfigEntity>(
|
||||
models: AnyModelConfig[]
|
||||
): T[] => {
|
||||
const createModelEntities = <T extends AnyModelConfigEntity>(models: AnyModelConfig[]): T[] => {
|
||||
const entityArray: T[] = [];
|
||||
models.forEach((model) => {
|
||||
const entity = {
|
||||
@ -201,10 +180,7 @@ const createModelEntities = <T extends AnyModelConfigEntity>(
|
||||
|
||||
export const modelsApi = api.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
getMainModels: build.query<
|
||||
EntityState<MainModelConfigEntity, string>,
|
||||
BaseModelType[]
|
||||
>({
|
||||
getMainModels: build.query<EntityState<MainModelConfigEntity, string>, BaseModelType[]>({
|
||||
query: (base_models) => {
|
||||
const params = {
|
||||
model_type: 'main',
|
||||
@ -215,10 +191,7 @@ export const modelsApi = api.injectEndpoints({
|
||||
return `models/?${query}`;
|
||||
},
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'MainModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'MainModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -232,19 +205,11 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: MainModelConfig[] }) => {
|
||||
const entities = createModelEntities<MainModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return mainModelsAdapter.setAll(
|
||||
mainModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<MainModelConfigEntity>(response.models);
|
||||
return mainModelsAdapter.setAll(mainModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
updateMainModels: build.mutation<
|
||||
UpdateMainModelResponse,
|
||||
UpdateMainModelArg
|
||||
>({
|
||||
updateMainModels: build.mutation<UpdateMainModelResponse, UpdateMainModelArg>({
|
||||
query: ({ base_model, model_name, body }) => {
|
||||
return {
|
||||
url: `models/${base_model}/main/${model_name}`,
|
||||
@ -254,10 +219,7 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: ['Model'],
|
||||
}),
|
||||
importMainModels: build.mutation<
|
||||
ImportMainModelResponse,
|
||||
ImportMainModelArg
|
||||
>({
|
||||
importMainModels: build.mutation<ImportMainModelResponse, ImportMainModelArg>({
|
||||
query: ({ body }) => {
|
||||
return {
|
||||
url: `models/import`,
|
||||
@ -277,10 +239,7 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: ['Model'],
|
||||
}),
|
||||
deleteMainModels: build.mutation<
|
||||
DeleteMainModelResponse,
|
||||
DeleteMainModelArg
|
||||
>({
|
||||
deleteMainModels: build.mutation<DeleteMainModelResponse, DeleteMainModelArg>({
|
||||
query: ({ base_model, model_name, model_type }) => {
|
||||
return {
|
||||
url: `models/${base_model}/${model_type}/${model_name}`,
|
||||
@ -289,10 +248,7 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: ['Model'],
|
||||
}),
|
||||
convertMainModels: build.mutation<
|
||||
ConvertMainModelResponse,
|
||||
ConvertMainModelArg
|
||||
>({
|
||||
convertMainModels: build.mutation<ConvertMainModelResponse, ConvertMainModelArg>({
|
||||
query: ({ base_model, model_name, convert_dest_directory }) => {
|
||||
return {
|
||||
url: `models/convert/${base_model}/main/${model_name}`,
|
||||
@ -321,16 +277,10 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: ['Model'],
|
||||
}),
|
||||
getLoRAModels: build.query<
|
||||
EntityState<LoRAModelConfigEntity, string>,
|
||||
void
|
||||
>({
|
||||
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'LoRAModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'LoRAModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -344,19 +294,11 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: LoRAModelConfig[] }) => {
|
||||
const entities = createModelEntities<LoRAModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return loraModelsAdapter.setAll(
|
||||
loraModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<LoRAModelConfigEntity>(response.models);
|
||||
return loraModelsAdapter.setAll(loraModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
updateLoRAModels: build.mutation<
|
||||
UpdateLoRAModelResponse,
|
||||
UpdateLoRAModelArg
|
||||
>({
|
||||
updateLoRAModels: build.mutation<UpdateLoRAModelResponse, UpdateLoRAModelArg>({
|
||||
query: ({ base_model, model_name, body }) => {
|
||||
return {
|
||||
url: `models/${base_model}/lora/${model_name}`,
|
||||
@ -366,10 +308,7 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: [{ type: 'LoRAModel', id: LIST_TAG }],
|
||||
}),
|
||||
deleteLoRAModels: build.mutation<
|
||||
DeleteLoRAModelResponse,
|
||||
DeleteLoRAModelArg
|
||||
>({
|
||||
deleteLoRAModels: build.mutation<DeleteLoRAModelResponse, DeleteLoRAModelArg>({
|
||||
query: ({ base_model, model_name }) => {
|
||||
return {
|
||||
url: `models/${base_model}/lora/${model_name}`,
|
||||
@ -378,16 +317,10 @@ export const modelsApi = api.injectEndpoints({
|
||||
},
|
||||
invalidatesTags: [{ type: 'LoRAModel', id: LIST_TAG }],
|
||||
}),
|
||||
getControlNetModels: build.query<
|
||||
EntityState<ControlNetModelConfigEntity, string>,
|
||||
void
|
||||
>({
|
||||
getControlNetModels: build.query<EntityState<ControlNetModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'controlnet' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'ControlNetModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'ControlNetModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -401,25 +334,14 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: ControlNetModelConfig[] }) => {
|
||||
const entities = createModelEntities<ControlNetModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return controlNetModelsAdapter.setAll(
|
||||
controlNetModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<ControlNetModelConfigEntity>(response.models);
|
||||
return controlNetModelsAdapter.setAll(controlNetModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
getIPAdapterModels: build.query<
|
||||
EntityState<IPAdapterModelConfigEntity, string>,
|
||||
void
|
||||
>({
|
||||
getIPAdapterModels: build.query<EntityState<IPAdapterModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'ip_adapter' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'IPAdapterModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'IPAdapterModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -433,25 +355,14 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: IPAdapterModelConfig[] }) => {
|
||||
const entities = createModelEntities<IPAdapterModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return ipAdapterModelsAdapter.setAll(
|
||||
ipAdapterModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<IPAdapterModelConfigEntity>(response.models);
|
||||
return ipAdapterModelsAdapter.setAll(ipAdapterModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
getT2IAdapterModels: build.query<
|
||||
EntityState<T2IAdapterModelConfigEntity, string>,
|
||||
void
|
||||
>({
|
||||
getT2IAdapterModels: build.query<EntityState<T2IAdapterModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 't2i_adapter' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'T2IAdapterModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'T2IAdapterModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -465,22 +376,14 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: T2IAdapterModelConfig[] }) => {
|
||||
const entities = createModelEntities<T2IAdapterModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return t2iAdapterModelsAdapter.setAll(
|
||||
t2iAdapterModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<T2IAdapterModelConfigEntity>(response.models);
|
||||
return t2iAdapterModelsAdapter.setAll(t2iAdapterModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
getVaeModels: build.query<EntityState<VaeModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'vae' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'VaeModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'VaeModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -494,25 +397,14 @@ export const modelsApi = api.injectEndpoints({
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: { models: VaeModelConfig[] }) => {
|
||||
const entities = createModelEntities<VaeModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return vaeModelsAdapter.setAll(
|
||||
vaeModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
const entities = createModelEntities<VaeModelConfigEntity>(response.models);
|
||||
return vaeModelsAdapter.setAll(vaeModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
getTextualInversionModels: build.query<
|
||||
EntityState<TextualInversionModelConfigEntity, string>,
|
||||
void
|
||||
>({
|
||||
getTextualInversionModels: build.query<EntityState<TextualInversionModelConfigEntity, string>, void>({
|
||||
query: () => ({ url: 'models/', params: { model_type: 'embedding' } }),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
{ type: 'TextualInversionModel', id: LIST_TAG },
|
||||
'Model',
|
||||
];
|
||||
const tags: ApiTagDescription[] = [{ type: 'TextualInversionModel', id: LIST_TAG }, 'Model'];
|
||||
|
||||
if (result) {
|
||||
tags.push(
|
||||
@ -525,16 +417,9 @@ export const modelsApi = api.injectEndpoints({
|
||||
|
||||
return tags;
|
||||
},
|
||||
transformResponse: (response: {
|
||||
models: TextualInversionModelConfig[];
|
||||
}) => {
|
||||
const entities = createModelEntities<TextualInversionModelConfigEntity>(
|
||||
response.models
|
||||
);
|
||||
return textualInversionModelsAdapter.setAll(
|
||||
textualInversionModelsAdapter.getInitialState(),
|
||||
entities
|
||||
);
|
||||
transformResponse: (response: { models: TextualInversionModelConfig[] }) => {
|
||||
const entities = createModelEntities<TextualInversionModelConfigEntity>(response.models);
|
||||
return textualInversionModelsAdapter.setAll(textualInversionModelsAdapter.getInitialState(), entities);
|
||||
},
|
||||
}),
|
||||
getModelsInFolder: build.query<SearchFolderResponse, SearchFolderArg>({
|
||||
|
@ -1,8 +1,4 @@
|
||||
import type {
|
||||
EntityState,
|
||||
ThunkDispatch,
|
||||
UnknownAction,
|
||||
} from '@reduxjs/toolkit';
|
||||
import type { EntityState, ThunkDispatch, UnknownAction } from '@reduxjs/toolkit';
|
||||
import { createEntityAdapter } from '@reduxjs/toolkit';
|
||||
import { getSelectorsOptions } from 'app/store/createMemoizedSelector';
|
||||
import { $queueId } from 'app/store/nanostores/queueId';
|
||||
@ -13,9 +9,7 @@ import type { components, paths } from 'services/api/schema';
|
||||
import type { ApiTagDescription } from '..';
|
||||
import { api } from '..';
|
||||
|
||||
const getListQueueItemsUrl = (
|
||||
queryArgs?: paths['/api/v1/queue/{queue_id}/list']['get']['parameters']['query']
|
||||
) => {
|
||||
const getListQueueItemsUrl = (queryArgs?: paths['/api/v1/queue/{queue_id}/list']['get']['parameters']['query']) => {
|
||||
const query = queryArgs
|
||||
? queryString.stringify(queryArgs, {
|
||||
arrayFormat: 'none',
|
||||
@ -30,15 +24,10 @@ const getListQueueItemsUrl = (
|
||||
};
|
||||
|
||||
export type SessionQueueItemStatus = NonNullable<
|
||||
NonNullable<
|
||||
paths['/api/v1/queue/{queue_id}/list']['get']['parameters']['query']
|
||||
>['status']
|
||||
NonNullable<paths['/api/v1/queue/{queue_id}/list']['get']['parameters']['query']>['status']
|
||||
>;
|
||||
|
||||
export const queueItemsAdapter = createEntityAdapter<
|
||||
components['schemas']['SessionQueueItemDTO'],
|
||||
string
|
||||
>({
|
||||
export const queueItemsAdapter = createEntityAdapter<components['schemas']['SessionQueueItemDTO'], string>({
|
||||
selectId: (queueItem) => String(queueItem.item_id),
|
||||
sortComparer: (a, b) => {
|
||||
// Sort by priority in descending order
|
||||
@ -60,10 +49,7 @@ export const queueItemsAdapter = createEntityAdapter<
|
||||
return 0;
|
||||
},
|
||||
});
|
||||
export const queueItemsAdapterSelectors = queueItemsAdapter.getSelectors(
|
||||
undefined,
|
||||
getSelectorsOptions
|
||||
);
|
||||
export const queueItemsAdapterSelectors = queueItemsAdapter.getSelectors(undefined, getSelectorsOptions);
|
||||
|
||||
export const queueApi = api.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
@ -76,11 +62,7 @@ export const queueApi = api.injectEndpoints({
|
||||
body: arg,
|
||||
method: 'POST',
|
||||
}),
|
||||
invalidatesTags: [
|
||||
'SessionQueueStatus',
|
||||
'CurrentSessionQueueItem',
|
||||
'NextSessionQueueItem',
|
||||
],
|
||||
invalidatesTags: ['SessionQueueStatus', 'CurrentSessionQueueItem', 'NextSessionQueueItem'],
|
||||
onQueryStarted: async (arg, api) => {
|
||||
const { dispatch, queryFulfilled } = api;
|
||||
try {
|
||||
@ -164,10 +146,7 @@ export const queueApi = api.injectEndpoints({
|
||||
method: 'GET',
|
||||
}),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
'CurrentSessionQueueItem',
|
||||
'FetchOnReconnect',
|
||||
];
|
||||
const tags: ApiTagDescription[] = ['CurrentSessionQueueItem', 'FetchOnReconnect'];
|
||||
if (result) {
|
||||
tags.push({ type: 'SessionQueueItem', id: result.item_id });
|
||||
}
|
||||
@ -183,10 +162,7 @@ export const queueApi = api.injectEndpoints({
|
||||
method: 'GET',
|
||||
}),
|
||||
providesTags: (result) => {
|
||||
const tags: ApiTagDescription[] = [
|
||||
'NextSessionQueueItem',
|
||||
'FetchOnReconnect',
|
||||
];
|
||||
const tags: ApiTagDescription[] = ['NextSessionQueueItem', 'FetchOnReconnect'];
|
||||
if (result) {
|
||||
tags.push({ type: 'SessionQueueItem', id: result.item_id });
|
||||
}
|
||||
@ -247,20 +223,16 @@ export const queueApi = api.injectEndpoints({
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
dispatch(
|
||||
queueApi.util.updateQueryData(
|
||||
'listQueueItems',
|
||||
undefined,
|
||||
(draft) => {
|
||||
queueItemsAdapter.updateOne(draft, {
|
||||
id: String(item_id),
|
||||
changes: {
|
||||
status: data.status,
|
||||
completed_at: data.completed_at,
|
||||
updated_at: data.updated_at,
|
||||
},
|
||||
});
|
||||
}
|
||||
)
|
||||
queueApi.util.updateQueryData('listQueueItems', undefined, (draft) => {
|
||||
queueItemsAdapter.updateOne(draft, {
|
||||
id: String(item_id),
|
||||
changes: {
|
||||
status: data.status,
|
||||
completed_at: data.completed_at,
|
||||
updated_at: data.updated_at,
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
// no-op
|
||||
@ -309,9 +281,7 @@ export const queueApi = api.injectEndpoints({
|
||||
serializeQueryArgs: () => {
|
||||
return `queue/${$queueId.get()}/list`;
|
||||
},
|
||||
transformResponse: (
|
||||
response: components['schemas']['CursorPaginatedResults_SessionQueueItemDTO_']
|
||||
) =>
|
||||
transformResponse: (response: components['schemas']['CursorPaginatedResults_SessionQueueItemDTO_']) =>
|
||||
queueItemsAdapter.addMany(
|
||||
queueItemsAdapter.getInitialState({
|
||||
has_more: response.has_more,
|
||||
@ -319,10 +289,7 @@ export const queueApi = api.injectEndpoints({
|
||||
response.items
|
||||
),
|
||||
merge: (cache, response) => {
|
||||
queueItemsAdapter.addMany(
|
||||
cache,
|
||||
queueItemsAdapterSelectors.selectAll(response)
|
||||
);
|
||||
queueItemsAdapter.addMany(cache, queueItemsAdapterSelectors.selectAll(response));
|
||||
cache.has_more = response.has_more;
|
||||
},
|
||||
forceRefetch: ({ currentArg, previousArg }) => currentArg !== previousArg,
|
||||
|
@ -9,19 +9,12 @@ export const workflowsApi = api.injectEndpoints({
|
||||
string
|
||||
>({
|
||||
query: (workflow_id) => `workflows/i/${workflow_id}`,
|
||||
providesTags: (result, error, workflow_id) => [
|
||||
{ type: 'Workflow', id: workflow_id },
|
||||
'FetchOnReconnect',
|
||||
],
|
||||
providesTags: (result, error, workflow_id) => [{ type: 'Workflow', id: workflow_id }, 'FetchOnReconnect'],
|
||||
onQueryStarted: async (arg, api) => {
|
||||
const { dispatch, queryFulfilled } = api;
|
||||
try {
|
||||
await queryFulfilled;
|
||||
dispatch(
|
||||
workflowsApi.util.invalidateTags([
|
||||
{ type: 'WorkflowsRecent', id: LIST_TAG },
|
||||
])
|
||||
);
|
||||
dispatch(workflowsApi.util.invalidateTags([{ type: 'WorkflowsRecent', id: LIST_TAG }]));
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
Reference in New Issue
Block a user