mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): sort model select options with compatible base model first
This commit is contained in:
committed by
Kent Keirsey
parent
e32eb2a649
commit
77f2aabda4
@@ -1,4 +1,5 @@
|
||||
import type { EntityState } from '@reduxjs/toolkit';
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import type { GroupBase } from 'chakra-react-select';
|
||||
import { groupBy, map, reduce } from 'lodash-es';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
@@ -28,6 +29,9 @@ export const useGroupedModelInvSelect = <T extends AnyModelConfigEntity>(
|
||||
arg: UseGroupedModelInvSelectArg<T>
|
||||
): UseGroupedModelInvSelectReturn => {
|
||||
const { t } = useTranslation();
|
||||
const base_model = useAppSelector(
|
||||
(state) => state.generation.model?.base_model ?? 'sdxl'
|
||||
);
|
||||
const { modelEntities, selectedModel, getIsDisabled, onChange, isLoading } =
|
||||
arg;
|
||||
const options = useMemo(() => {
|
||||
@@ -51,8 +55,9 @@ export const useGroupedModelInvSelect = <T extends AnyModelConfigEntity>(
|
||||
},
|
||||
[] as GroupBase<InvSelectOption>[]
|
||||
);
|
||||
_options.sort((a) => (a.label === base_model ? -1 : 1));
|
||||
return _options;
|
||||
}, [getIsDisabled, modelEntities]);
|
||||
}, [getIsDisabled, modelEntities, base_model]);
|
||||
|
||||
const value = useMemo(
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user