fix(ui): fix controlnet selects data types

This commit is contained in:
psychedelicious 2023-06-14 13:19:51 +10:00
parent 6c551df311
commit 70ffd6b03f
2 changed files with 19 additions and 8 deletions

View File

@ -1,6 +1,8 @@
import { createSelector } from '@reduxjs/toolkit'; import { createSelector } from '@reduxjs/toolkit';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAIMantineSelect from 'common/components/IAIMantineSelect'; import IAIMantineSelect, {
IAISelectDataType,
} from 'common/components/IAIMantineSelect';
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke'; import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
import { import {
CONTROLNET_MODELS, CONTROLNET_MODELS,
@ -17,7 +19,7 @@ type ParamControlNetModelProps = {
}; };
const selector = createSelector(configSelector, (config) => { const selector = createSelector(configSelector, (config) => {
return map(CONTROLNET_MODELS, (m) => ({ const controlNetModels: IAISelectDataType[] = map(CONTROLNET_MODELS, (m) => ({
label: m.label, label: m.label,
value: m.type, value: m.type,
})).filter( })).filter(
@ -26,6 +28,8 @@ const selector = createSelector(configSelector, (config) => {
d.value as ControlNetModelName d.value as ControlNetModelName
) )
); );
return controlNetModels;
}); });
const ParamControlNetModel = (props: ParamControlNetModelProps) => { const ParamControlNetModel = (props: ParamControlNetModelProps) => {

View File

@ -1,6 +1,8 @@
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAIMantineSelect from 'common/components/IAIMantineSelect'; import IAIMantineSelect, {
IAISelectDataType,
} from 'common/components/IAIMantineSelect';
import { map } from 'lodash-es'; import { map } from 'lodash-es';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
import { CONTROLNET_PROCESSORS } from '../../store/constants'; import { CONTROLNET_PROCESSORS } from '../../store/constants';
@ -22,17 +24,20 @@ type ParamControlNetProcessorSelectProps = {
const selector = createSelector( const selector = createSelector(
configSelector, configSelector,
(config) => { (config) => {
return map(CONTROLNET_PROCESSORS, (p) => ({ const controlNetProcessors: IAISelectDataType[] = map(
value: p.type, CONTROLNET_PROCESSORS,
key: p.label, (p) => ({
})) value: p.type,
label: p.label,
})
)
.sort((a, b) => .sort((a, b) =>
// sort 'none' to the top // sort 'none' to the top
a.value === 'none' a.value === 'none'
? -1 ? -1
: b.value === 'none' : b.value === 'none'
? 1 ? 1
: a.key.localeCompare(b.key) : a.label.localeCompare(b.label)
) )
.filter( .filter(
(d) => (d) =>
@ -40,6 +45,8 @@ const selector = createSelector(
d.value as ControlNetProcessorType d.value as ControlNetProcessorType
) )
); );
return controlNetProcessors;
}, },
defaultSelectorOptions defaultSelectorOptions
); );