mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): remove unnecessary tabChanged listener
This was needed when we didn't support SDXL on canvas.
This commit is contained in:
parent
da5907613b
commit
63d74b4ba6
@ -69,7 +69,6 @@ import { addSessionRetrievalErrorEventListener } from './listeners/socketio/sock
|
|||||||
import { addSocketSubscribedEventListener as addSocketSubscribedListener } from './listeners/socketio/socketSubscribed';
|
import { addSocketSubscribedEventListener as addSocketSubscribedListener } from './listeners/socketio/socketSubscribed';
|
||||||
import { addSocketUnsubscribedEventListener as addSocketUnsubscribedListener } from './listeners/socketio/socketUnsubscribed';
|
import { addSocketUnsubscribedEventListener as addSocketUnsubscribedListener } from './listeners/socketio/socketUnsubscribed';
|
||||||
import { addStagingAreaImageSavedListener } from './listeners/stagingAreaImageSaved';
|
import { addStagingAreaImageSavedListener } from './listeners/stagingAreaImageSaved';
|
||||||
import { addTabChangedListener } from './listeners/tabChanged';
|
|
||||||
import { addUpdateAllNodesRequestedListener } from './listeners/updateAllNodesRequested';
|
import { addUpdateAllNodesRequestedListener } from './listeners/updateAllNodesRequested';
|
||||||
import { addUpscaleRequestedListener } from './listeners/upscaleRequested';
|
import { addUpscaleRequestedListener } from './listeners/upscaleRequested';
|
||||||
import { addWorkflowLoadRequestedListener } from './listeners/workflowLoadRequested';
|
import { addWorkflowLoadRequestedListener } from './listeners/workflowLoadRequested';
|
||||||
@ -196,8 +195,5 @@ addFirstListImagesListener();
|
|||||||
// Ad-hoc upscale workflwo
|
// Ad-hoc upscale workflwo
|
||||||
addUpscaleRequestedListener();
|
addUpscaleRequestedListener();
|
||||||
|
|
||||||
// Tab Change
|
|
||||||
addTabChangedListener();
|
|
||||||
|
|
||||||
// Dynamic prompts
|
// Dynamic prompts
|
||||||
addDynamicPromptsListener();
|
addDynamicPromptsListener();
|
||||||
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user