From 3f61c51c3a7f3bab659f979d0c330ed8f449013a Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:31:40 +1100 Subject: [PATCH] fix(ui): model list refreshes after changes When consolidating all the model queries I messed up the query tags. Fixed now, so that when a model is installed, removed, or changed, the list refreshes. --- .../listeners/socketio/socketModelInstall.ts | 4 ++-- .../web/src/services/api/endpoints/models.ts | 16 ++++++++-------- invokeai/frontend/web/src/services/api/index.ts | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketModelInstall.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketModelInstall.ts index 33940b9c55..4d04ef92be 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketModelInstall.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketModelInstall.ts @@ -1,5 +1,5 @@ import type { AppStartListening } from 'app/store/middleware/listenerMiddleware'; -import { api } from 'services/api'; +import { api, LIST_TAG } from 'services/api'; import { modelsApi } from 'services/api/endpoints/models'; import { socketModelInstallCancelled, @@ -42,7 +42,7 @@ export const addModelInstallEventListener = (startAppListening: AppStartListenin return draft; }) ); - dispatch(api.util.invalidateTags(['Model'])); + dispatch(api.util.invalidateTags([{ type: 'ModelConfig', id: LIST_TAG }])); }, }); diff --git a/invokeai/frontend/web/src/services/api/endpoints/models.ts b/invokeai/frontend/web/src/services/api/endpoints/models.ts index 603edb4c27..6dd74b22d9 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/models.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/models.ts @@ -118,7 +118,7 @@ export const modelsApi = api.injectEndpoints({ body: formData, }; }, - invalidatesTags: ['Model'], + invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }], }), installModel: build.mutation({ query: ({ source, inplace = true }) => { @@ -128,7 +128,7 @@ export const modelsApi = api.injectEndpoints({ method: 'POST', }; }, - invalidatesTags: ['Model', 'ModelInstalls'], + invalidatesTags: ['ModelInstalls'], }), deleteModels: build.mutation({ query: ({ key }) => { @@ -137,7 +137,7 @@ export const modelsApi = api.injectEndpoints({ method: 'DELETE', }; }, - invalidatesTags: ['Model'], + invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }], }), deleteModelImage: build.mutation({ query: (key) => { @@ -146,7 +146,7 @@ export const modelsApi = api.injectEndpoints({ method: 'DELETE', }; }, - invalidatesTags: ['Model'], + invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }], }), getModelImage: build.query({ query: (key) => buildModelsUrl(`i/${key}/image`), @@ -158,12 +158,12 @@ export const modelsApi = api.injectEndpoints({ method: 'PUT', }; }, - invalidatesTags: ['ModelConfig'], + invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }], }), getModelConfig: build.query({ query: (key) => buildModelsUrl(`i/${key}`), providesTags: (result) => { - const tags: ApiTagDescription[] = ['Model']; + const tags: ApiTagDescription[] = []; if (result) { tags.push({ type: 'ModelConfig', id: result.key }); @@ -175,7 +175,7 @@ export const modelsApi = api.injectEndpoints({ getModelConfigByAttrs: build.query({ query: (arg) => buildModelsUrl(`get_by_attrs?${queryString.stringify(arg)}`), providesTags: (result) => { - const tags: ApiTagDescription[] = ['Model']; + const tags: ApiTagDescription[] = []; if (result) { tags.push({ type: 'ModelConfig', id: result.key }); @@ -192,7 +192,7 @@ export const modelsApi = api.injectEndpoints({ method: 'PATCH', }; }, - invalidatesTags: ['Model'], + invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }], }), scanFolder: build.query({ query: (arg) => { diff --git a/invokeai/frontend/web/src/services/api/index.ts b/invokeai/frontend/web/src/services/api/index.ts index 35e7826c30..63b34a08ad 100644 --- a/invokeai/frontend/web/src/services/api/index.ts +++ b/invokeai/frontend/web/src/services/api/index.ts @@ -26,7 +26,6 @@ export const tagTypes = [ 'NextSessionQueueItem', 'BatchStatus', 'InvocationCacheStatus', - 'Model', 'ModelConfig', 'ModelInstalls', 'T2IAdapterModel',