diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/index.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/index.ts index c3fdefbab9..47136211a8 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/index.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/index.ts @@ -69,7 +69,6 @@ import { addSessionRetrievalErrorEventListener } from './listeners/socketio/sock import { addSocketSubscribedEventListener as addSocketSubscribedListener } from './listeners/socketio/socketSubscribed'; import { addSocketUnsubscribedEventListener as addSocketUnsubscribedListener } from './listeners/socketio/socketUnsubscribed'; import { addStagingAreaImageSavedListener } from './listeners/stagingAreaImageSaved'; -import { addTabChangedListener } from './listeners/tabChanged'; import { addUpdateAllNodesRequestedListener } from './listeners/updateAllNodesRequested'; import { addUpscaleRequestedListener } from './listeners/upscaleRequested'; import { addWorkflowLoadRequestedListener } from './listeners/workflowLoadRequested'; @@ -196,8 +195,5 @@ addFirstListImagesListener(); // Ad-hoc upscale workflwo addUpscaleRequestedListener(); -// Tab Change -addTabChangedListener(); - // Dynamic prompts addDynamicPromptsListener(); diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/tabChanged.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/tabChanged.ts deleted file mode 100644 index e1c384ad53..0000000000 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/tabChanged.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { modelChanged } from 'features/parameters/store/generationSlice'; -import { setActiveTab } from 'features/ui/store/uiSlice'; -import { NON_REFINER_BASE_MODELS } from 'services/api/constants'; -import { - mainModelsAdapterSelectors, - modelsApi, -} from 'services/api/endpoints/models'; - -import { startAppListening } from '..'; - -export const addTabChangedListener = () => { - startAppListening({ - actionCreator: setActiveTab, - effect: async (action, { getState, dispatch }) => { - const activeTabName = action.payload; - if (activeTabName === 'unifiedCanvas') { - const currentBaseModel = getState().generation.model?.base_model; - - if ( - currentBaseModel && - ['sd-1', 'sd-2', 'sdxl'].includes(currentBaseModel) - ) { - // if we're already on a valid model, no change needed - return; - } - - try { - // just grab fresh models - const modelsRequest = dispatch( - modelsApi.endpoints.getMainModels.initiate(NON_REFINER_BASE_MODELS) - ); - const models = await modelsRequest.unwrap(); - // cancel this cache subscription - modelsRequest.unsubscribe(); - - if (!models.ids.length) { - // no valid canvas models - dispatch(modelChanged(null)); - return; - } - - // need to filter out all the invalid canvas models (currently refiner & any) - const validCanvasModels = mainModelsAdapterSelectors - .selectAll(models) - .filter((model) => - ['sd-1', 'sd-2', 'sdxl'].includes(model.base_model) - ); - - const firstValidCanvasModel = validCanvasModels[0]; - - if (!firstValidCanvasModel) { - // no valid canvas models - dispatch(modelChanged(null)); - return; - } - - const { base_model, model_name, model_type } = firstValidCanvasModel; - - dispatch(modelChanged({ base_model, model_name, model_type })); - } catch { - // network request failed, bail - dispatch(modelChanged(null)); - } - } - }, - }); -};