fix(ui): resolve merge conflicts

This commit is contained in:
psychedelicious 2023-07-07 22:48:25 +10:00
parent 8457fcf7d3
commit 2cbe98b1b1
2 changed files with 22 additions and 12 deletions

View File

@ -2,7 +2,7 @@ import { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAISlider from 'common/components/IAISlider'; import IAISlider from 'common/components/IAISlider';
import { setClipSkip } from 'features/parameters/store/generationSlice'; import { setClipSkip } from 'features/parameters/store/generationSlice';
import { useCallback } from 'react'; import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export const clipSkipMap = { export const clipSkipMap = {
@ -21,9 +21,7 @@ export default function ParamClipSkip() {
(state: RootState) => state.generation.clipSkip (state: RootState) => state.generation.clipSkip
); );
const selectedModelId = useAppSelector( const { model } = useAppSelector((state: RootState) => state.generation);
(state: RootState) => state.generation.model
).split('/')[0];
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
@ -39,19 +37,31 @@ export default function ParamClipSkip() {
dispatch(setClipSkip(0)); dispatch(setClipSkip(0));
}, [dispatch]); }, [dispatch]);
const max = useMemo(() => {
if (!model) {
return clipSkipMap['sd-1'].maxClip;
}
return clipSkipMap[model.base_model].maxClip;
}, [model]);
const sliderMarks = useMemo(() => {
if (!model) {
return clipSkipMap['sd-1'].markers;
}
return clipSkipMap[model.base_model].markers;
}, [model]);
return ( return (
<IAISlider <IAISlider
label={t('parameters.clipSkip')} label={t('parameters.clipSkip')}
aria-label={t('parameters.clipSkip')} aria-label={t('parameters.clipSkip')}
min={0} min={0}
max={clipSkipMap[selectedModelId as keyof typeof clipSkipMap].maxClip} max={max}
step={1} step={1}
value={clipSkip} value={clipSkip}
onChange={handleClipSkipChange} onChange={handleClipSkipChange}
withSliderMarks withSliderMarks
sliderMarks={ sliderMarks={sliderMarks}
clipSkipMap[selectedModelId as keyof typeof clipSkipMap].markers
}
withInput withInput
withReset withReset
handleReset={handleClipSkipReset} handleReset={handleClipSkipReset}

View File

@ -219,16 +219,16 @@ export const generationSlice = createSlice({
modelSelected: (state, action: PayloadAction<string>) => { modelSelected: (state, action: PayloadAction<string>) => {
const [base_model, type, name] = action.payload.split('/'); const [base_model, type, name] = action.payload.split('/');
// Clamp ClipSkip Based On Selected Model
const { maxClip } = clipSkipMap[base_model as keyof typeof clipSkipMap];
state.clipSkip = clamp(state.clipSkip, 0, maxClip);
state.model = zMainModel.parse({ state.model = zMainModel.parse({
id: action.payload, id: action.payload,
base_model, base_model,
name, name,
type, type,
}); });
// Clamp ClipSkip Based On Selected Model
const { maxClip } = clipSkipMap[state.model.base_model];
state.clipSkip = clamp(state.clipSkip, 0, maxClip);
}, },
modelChanged: (state, action: PayloadAction<MainModelParam>) => { modelChanged: (state, action: PayloadAction<MainModelParam>) => {
state.model = action.payload; state.model = action.payload;