mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
restore redux action for model changed so that model actually changes
This commit is contained in:
parent
4bbe6f3548
commit
dc7154439d
@ -1,9 +1,9 @@
|
|||||||
import { isAnyOf } from '@reduxjs/toolkit';
|
import { isAnyOf } from '@reduxjs/toolkit';
|
||||||
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
|
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
|
||||||
import { controlAdapterModelChanged } from 'features/controlAdapters/store/actions';
|
|
||||||
import { CONTROLNET_MODEL_DEFAULT_PROCESSORS } from 'features/controlAdapters/store/constants';
|
import { CONTROLNET_MODEL_DEFAULT_PROCESSORS } from 'features/controlAdapters/store/constants';
|
||||||
import {
|
import {
|
||||||
controlAdapterAutoConfigToggled,
|
controlAdapterAutoConfigToggled,
|
||||||
|
controlAdapterModelChanged,
|
||||||
controlAdapterProcessortTypeChanged,
|
controlAdapterProcessortTypeChanged,
|
||||||
selectControlAdapterById,
|
selectControlAdapterById,
|
||||||
} from 'features/controlAdapters/store/controlAdaptersSlice';
|
} from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||||
|
@ -2,10 +2,11 @@ import type { AnyListenerPredicate } from '@reduxjs/toolkit';
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
|
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
|
||||||
import type { RootState } from 'app/store/store';
|
import type { RootState } from 'app/store/store';
|
||||||
import { controlAdapterImageProcessed, controlAdapterModelChanged } from 'features/controlAdapters/store/actions';
|
import { controlAdapterImageProcessed } from 'features/controlAdapters/store/actions';
|
||||||
import {
|
import {
|
||||||
controlAdapterAutoConfigToggled,
|
controlAdapterAutoConfigToggled,
|
||||||
controlAdapterImageChanged,
|
controlAdapterImageChanged,
|
||||||
|
controlAdapterModelChanged,
|
||||||
controlAdapterProcessorParamsChanged,
|
controlAdapterProcessorParamsChanged,
|
||||||
controlAdapterProcessortTypeChanged,
|
controlAdapterProcessortTypeChanged,
|
||||||
selectControlAdapterById,
|
selectControlAdapterById,
|
||||||
|
@ -5,10 +5,10 @@ import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useCo
|
|||||||
import { useControlAdapterModel } from 'features/controlAdapters/hooks/useControlAdapterModel';
|
import { useControlAdapterModel } from 'features/controlAdapters/hooks/useControlAdapterModel';
|
||||||
import { useControlAdapterModelQuery } from 'features/controlAdapters/hooks/useControlAdapterModelQuery';
|
import { useControlAdapterModelQuery } from 'features/controlAdapters/hooks/useControlAdapterModelQuery';
|
||||||
import { useControlAdapterType } from 'features/controlAdapters/hooks/useControlAdapterType';
|
import { useControlAdapterType } from 'features/controlAdapters/hooks/useControlAdapterType';
|
||||||
import { controlAdapterModelChanged } from 'features/controlAdapters/store/actions';
|
|
||||||
import { getModelKeyAndBase } from 'features/metadata/util/modelFetchingHelpers';
|
import { getModelKeyAndBase } from 'features/metadata/util/modelFetchingHelpers';
|
||||||
import { memo, useCallback, useMemo } from 'react';
|
import { memo, useCallback, useMemo } from 'react';
|
||||||
import type { ControlNetModelConfig, IPAdapterModelConfig, T2IAdapterModelConfig } from 'services/api/types';
|
import type { ControlNetModelConfig, IPAdapterModelConfig, T2IAdapterModelConfig } from 'services/api/types';
|
||||||
|
import { controlAdapterModelChanged } from '../../store/controlAdaptersSlice';
|
||||||
|
|
||||||
type ParamControlAdapterModelProps = {
|
type ParamControlAdapterModelProps = {
|
||||||
id: string;
|
id: string;
|
||||||
@ -25,7 +25,6 @@ const ParamControlAdapterModel = ({ id }: ParamControlAdapterModelProps) => {
|
|||||||
|
|
||||||
const _onChange = useCallback(
|
const _onChange = useCallback(
|
||||||
(model: ControlNetModelConfig | IPAdapterModelConfig | T2IAdapterModelConfig | null) => {
|
(model: ControlNetModelConfig | IPAdapterModelConfig | T2IAdapterModelConfig | null) => {
|
||||||
console.log('on change');
|
|
||||||
if (!model) {
|
if (!model) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
import { createAction } from '@reduxjs/toolkit';
|
import { createAction } from '@reduxjs/toolkit';
|
||||||
import type {
|
|
||||||
ParameterControlNetModel,
|
|
||||||
ParameterIPAdapterModel,
|
|
||||||
ParameterT2IAdapterModel,
|
|
||||||
} from 'features/parameters/types/parameterSchemas';
|
|
||||||
|
|
||||||
export const controlAdapterImageProcessed = createAction<{
|
export const controlAdapterImageProcessed = createAction<{
|
||||||
id: string;
|
id: string;
|
||||||
}>('controlAdapters/imageProcessed');
|
}>('controlAdapters/imageProcessed');
|
||||||
|
|
||||||
export const controlAdapterModelChanged = createAction<{
|
|
||||||
id: string;
|
|
||||||
model: ParameterControlNetModel | ParameterT2IAdapterModel | ParameterIPAdapterModel;
|
|
||||||
}>('controlAdapters/controlAdapterModelChanged');
|
|
||||||
|
@ -21,6 +21,7 @@ import type {
|
|||||||
T2IAdapterConfig,
|
T2IAdapterConfig,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { isControlNet, isControlNetOrT2IAdapter, isIPAdapter, isT2IAdapter } from './types';
|
import { isControlNet, isControlNetOrT2IAdapter, isIPAdapter, isT2IAdapter } from './types';
|
||||||
|
import { ParameterControlNetModel, ParameterT2IAdapterModel, ParameterIPAdapterModel } from '../../parameters/types/parameterSchemas';
|
||||||
|
|
||||||
const caAdapter = createEntityAdapter<ControlAdapterConfig, string>({
|
const caAdapter = createEntityAdapter<ControlAdapterConfig, string>({
|
||||||
selectId: (ca) => ca.id,
|
selectId: (ca) => ca.id,
|
||||||
@ -182,6 +183,33 @@ export const controlAdaptersSlice = createSlice({
|
|||||||
changes: { model: null },
|
changes: { model: null },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
controlAdapterModelChanged: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<{
|
||||||
|
id: string;
|
||||||
|
model: ParameterControlNetModel | ParameterT2IAdapterModel | ParameterIPAdapterModel;
|
||||||
|
}>
|
||||||
|
) => {
|
||||||
|
const { id, model } = action.payload;
|
||||||
|
const cn = selectControlAdapterById(state, id);
|
||||||
|
if (!cn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isControlNetOrT2IAdapter(cn)) {
|
||||||
|
caAdapter.updateOne(state, { id, changes: { model } });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const update: Update<ControlNetConfig | T2IAdapterConfig, string> = {
|
||||||
|
id,
|
||||||
|
changes: { model, shouldAutoConfig: true },
|
||||||
|
};
|
||||||
|
|
||||||
|
update.changes.processedControlImage = null;
|
||||||
|
|
||||||
|
caAdapter.updateOne(state, update);
|
||||||
|
},
|
||||||
controlAdapterWeightChanged: (state, action: PayloadAction<{ id: string; weight: number }>) => {
|
controlAdapterWeightChanged: (state, action: PayloadAction<{ id: string; weight: number }>) => {
|
||||||
const { id, weight } = action.payload;
|
const { id, weight } = action.payload;
|
||||||
caAdapter.updateOne(state, { id, changes: { weight } });
|
caAdapter.updateOne(state, { id, changes: { weight } });
|
||||||
@ -319,6 +347,7 @@ export const {
|
|||||||
controlAdapterImageChanged,
|
controlAdapterImageChanged,
|
||||||
controlAdapterProcessedImageChanged,
|
controlAdapterProcessedImageChanged,
|
||||||
controlAdapterIsEnabledChanged,
|
controlAdapterIsEnabledChanged,
|
||||||
|
controlAdapterModelChanged,
|
||||||
controlAdapterWeightChanged,
|
controlAdapterWeightChanged,
|
||||||
controlAdapterBeginStepPctChanged,
|
controlAdapterBeginStepPctChanged,
|
||||||
controlAdapterEndStepPctChanged,
|
controlAdapterEndStepPctChanged,
|
||||||
|
Loading…
Reference in New Issue
Block a user