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 { 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 {
CONTROLNET_MODELS,
@ -17,7 +19,7 @@ type ParamControlNetModelProps = {
};
const selector = createSelector(configSelector, (config) => {
return map(CONTROLNET_MODELS, (m) => ({
const controlNetModels: IAISelectDataType[] = map(CONTROLNET_MODELS, (m) => ({
label: m.label,
value: m.type,
})).filter(
@ -26,6 +28,8 @@ const selector = createSelector(configSelector, (config) => {
d.value as ControlNetModelName
)
);
return controlNetModels;
});
const ParamControlNetModel = (props: ParamControlNetModelProps) => {

View File

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