mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): reset controlnet model to null instead of disabling when base model changes
This commit is contained in:
parent
56050f7887
commit
387ab9cee7
@ -1,7 +1,7 @@
|
||||
import { logger } from 'app/logging/logger';
|
||||
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
|
||||
import {
|
||||
controlAdapterIsEnabledChanged,
|
||||
controlAdapterModelChanged,
|
||||
selectControlAdapterAll,
|
||||
} from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||
import { loraRemoved } from 'features/lora/store/loraSlice';
|
||||
@ -54,7 +54,7 @@ export const addModelSelectedListener = (startAppListening: AppStartListening) =
|
||||
// handle incompatible controlnets
|
||||
selectControlAdapterAll(state.controlAdapters).forEach((ca) => {
|
||||
if (ca.model?.base !== newBaseModel) {
|
||||
dispatch(controlAdapterIsEnabledChanged({ id: ca.id, isEnabled: false }));
|
||||
dispatch(controlAdapterModelChanged({ id: ca.id, modelConfig: null }));
|
||||
modelsCleared += 1;
|
||||
}
|
||||
});
|
||||
|
@ -227,7 +227,7 @@ export const controlAdaptersSlice = createSlice({
|
||||
state,
|
||||
action: PayloadAction<{
|
||||
id: string;
|
||||
modelConfig: ControlNetModelConfig | T2IAdapterModelConfig | IPAdapterModelConfig;
|
||||
modelConfig: ControlNetModelConfig | T2IAdapterModelConfig | IPAdapterModelConfig | null;
|
||||
}>
|
||||
) => {
|
||||
const { id, modelConfig } = action.payload;
|
||||
@ -236,6 +236,11 @@ export const controlAdaptersSlice = createSlice({
|
||||
return;
|
||||
}
|
||||
|
||||
if (modelConfig === null) {
|
||||
caAdapter.updateOne(state, { id, changes: { model: null } });
|
||||
return;
|
||||
}
|
||||
|
||||
const model = zModelIdentifierField.parse(modelConfig);
|
||||
|
||||
if (!isControlNetOrT2IAdapter(cn)) {
|
||||
|
@ -8,7 +8,7 @@ export const useGetModelConfigWithTypeGuard = <T extends AnyModelConfig>(
|
||||
) => {
|
||||
const result = useGetModelConfigQuery(key ?? skipToken, {
|
||||
selectFromResult: (result) => {
|
||||
const modelConfig = result.data;
|
||||
const modelConfig = result.currentData;
|
||||
return {
|
||||
...result,
|
||||
modelConfig: modelConfig && typeGuard(modelConfig) ? modelConfig : undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user