mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): invalidate query cache for all models on sync models
Also realised the tags were set up incorrectly, fixed that to get type safety with tags.
This commit is contained in:
parent
1cc686734b
commit
a681fa4b03
@ -199,7 +199,10 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
return `models/?${query}`;
|
return `models/?${query}`;
|
||||||
},
|
},
|
||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [{ type: 'OnnxModel', id: LIST_TAG }];
|
const tags: ApiTagDescription[] = [
|
||||||
|
{ type: 'OnnxModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
tags.push(
|
tags.push(
|
||||||
@ -236,7 +239,10 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
return `models/?${query}`;
|
return `models/?${query}`;
|
||||||
},
|
},
|
||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [{ type: 'MainModel', id: LIST_TAG }];
|
const tags: ApiTagDescription[] = [
|
||||||
|
{ type: 'MainModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
tags.push(
|
tags.push(
|
||||||
@ -270,11 +276,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
body: body,
|
body: body,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
importMainModels: build.mutation<
|
importMainModels: build.mutation<
|
||||||
ImportMainModelResponse,
|
ImportMainModelResponse,
|
||||||
@ -287,11 +289,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
body: body,
|
body: body,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
addMainModels: build.mutation<AddMainModelResponse, AddMainModelArg>({
|
addMainModels: build.mutation<AddMainModelResponse, AddMainModelArg>({
|
||||||
query: ({ body }) => {
|
query: ({ body }) => {
|
||||||
@ -301,11 +299,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
body: body,
|
body: body,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
deleteMainModels: build.mutation<
|
deleteMainModels: build.mutation<
|
||||||
DeleteMainModelResponse,
|
DeleteMainModelResponse,
|
||||||
@ -317,11 +311,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
convertMainModels: build.mutation<
|
convertMainModels: build.mutation<
|
||||||
ConvertMainModelResponse,
|
ConvertMainModelResponse,
|
||||||
@ -334,11 +324,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
params: { convert_dest_directory },
|
params: { convert_dest_directory },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
mergeMainModels: build.mutation<MergeMainModelResponse, MergeMainModelArg>({
|
mergeMainModels: build.mutation<MergeMainModelResponse, MergeMainModelArg>({
|
||||||
query: ({ base_model, body }) => {
|
query: ({ base_model, body }) => {
|
||||||
@ -348,11 +334,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
body: body,
|
body: body,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
syncModels: build.mutation<SyncModelsResponse, void>({
|
syncModels: build.mutation<SyncModelsResponse, void>({
|
||||||
query: () => {
|
query: () => {
|
||||||
@ -361,16 +343,15 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
invalidatesTags: [
|
invalidatesTags: ['Model'],
|
||||||
{ type: 'MainModel', id: LIST_TAG },
|
|
||||||
{ type: 'SDXLRefinerModel', id: LIST_TAG },
|
|
||||||
{ type: 'OnnxModel', id: LIST_TAG },
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({
|
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({
|
||||||
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
|
||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [{ type: 'LoRAModel', id: LIST_TAG }];
|
const tags: ApiTagDescription[] = [
|
||||||
|
{ type: 'LoRAModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
tags.push(
|
tags.push(
|
||||||
@ -426,6 +407,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [
|
const tags: ApiTagDescription[] = [
|
||||||
{ type: 'ControlNetModel', id: LIST_TAG },
|
{ type: 'ControlNetModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -457,6 +439,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [
|
const tags: ApiTagDescription[] = [
|
||||||
{ type: 'IPAdapterModel', id: LIST_TAG },
|
{ type: 'IPAdapterModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -488,6 +471,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [
|
const tags: ApiTagDescription[] = [
|
||||||
{ type: 'T2IAdapterModel', id: LIST_TAG },
|
{ type: 'T2IAdapterModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -514,7 +498,10 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
getVaeModels: build.query<EntityState<VaeModelConfigEntity>, void>({
|
getVaeModels: build.query<EntityState<VaeModelConfigEntity>, void>({
|
||||||
query: () => ({ url: 'models/', params: { model_type: 'vae' } }),
|
query: () => ({ url: 'models/', params: { model_type: 'vae' } }),
|
||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [{ type: 'VaeModel', id: LIST_TAG }];
|
const tags: ApiTagDescription[] = [
|
||||||
|
{ type: 'VaeModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
tags.push(
|
tags.push(
|
||||||
@ -545,6 +532,7 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
providesTags: (result) => {
|
providesTags: (result) => {
|
||||||
const tags: ApiTagDescription[] = [
|
const tags: ApiTagDescription[] = [
|
||||||
{ type: 'TextualInversionModel', id: LIST_TAG },
|
{ type: 'TextualInversionModel', id: LIST_TAG },
|
||||||
|
'Model',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -577,21 +565,6 @@ export const modelsApi = api.injectEndpoints({
|
|||||||
url: `/models/search?${folderQueryStr}`,
|
url: `/models/search?${folderQueryStr}`,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
providesTags: (result) => {
|
|
||||||
const tags: ApiTagDescription[] = [
|
|
||||||
{ type: 'ScannedModels', id: LIST_TAG },
|
|
||||||
];
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
tags.push(
|
|
||||||
...result.map((id) => ({
|
|
||||||
type: 'ScannedModels' as const,
|
|
||||||
id,
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return tags;
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
getCheckpointConfigs: build.query<CheckpointConfigsResponse, void>({
|
getCheckpointConfigs: build.query<CheckpointConfigsResponse, void>({
|
||||||
query: () => {
|
query: () => {
|
||||||
|
@ -9,6 +9,8 @@ import {
|
|||||||
import { $authToken, $baseUrl, $projectId } from 'services/api/client';
|
import { $authToken, $baseUrl, $projectId } from 'services/api/client';
|
||||||
|
|
||||||
export const tagTypes = [
|
export const tagTypes = [
|
||||||
|
'AppVersion',
|
||||||
|
'AppConfig',
|
||||||
'Board',
|
'Board',
|
||||||
'BoardImagesTotal',
|
'BoardImagesTotal',
|
||||||
'BoardAssetsTotal',
|
'BoardAssetsTotal',
|
||||||
@ -17,15 +19,27 @@ export const tagTypes = [
|
|||||||
'ImageList',
|
'ImageList',
|
||||||
'ImageMetadata',
|
'ImageMetadata',
|
||||||
'ImageMetadataFromFile',
|
'ImageMetadataFromFile',
|
||||||
'Model',
|
'IntermediatesCount',
|
||||||
'SessionQueueItem',
|
'SessionQueueItem',
|
||||||
'SessionQueueItemDTO',
|
'SessionQueueItemDTO',
|
||||||
'SessionQueueItemDTOList',
|
'SessionQueueItemDTOList',
|
||||||
'SessionQueueStatus',
|
'SessionQueueStatus',
|
||||||
'SessionProcessorStatus',
|
'SessionProcessorStatus',
|
||||||
|
'CurrentSessionQueueItem',
|
||||||
|
'NextSessionQueueItem',
|
||||||
'BatchStatus',
|
'BatchStatus',
|
||||||
'InvocationCacheStatus',
|
'InvocationCacheStatus',
|
||||||
];
|
'Model',
|
||||||
|
'T2IAdapterModel',
|
||||||
|
'MainModel',
|
||||||
|
'OnnxModel',
|
||||||
|
'VaeModel',
|
||||||
|
'IPAdapterModel',
|
||||||
|
'TextualInversionModel',
|
||||||
|
'ControlNetModel',
|
||||||
|
'LoRAModel',
|
||||||
|
'SDXLRefinerModel',
|
||||||
|
] as const;
|
||||||
export type ApiTagDescription = TagDescription<(typeof tagTypes)[number]>;
|
export type ApiTagDescription = TagDescription<(typeof tagTypes)[number]>;
|
||||||
export const LIST_TAG = 'LIST';
|
export const LIST_TAG = 'LIST';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user