tidy(ui): remove unused files, exports

This commit is contained in:
psychedelicious 2024-03-28 10:41:36 +11:00
parent 33900d2419
commit 6e5b4b595a
4 changed files with 1 additions and 98 deletions

View File

@ -1,83 +0,0 @@
import type { Item } from '@invoke-ai/ui-library';
import type { ModelIdentifierField } from 'features/nodes/types/common';
import { MODEL_TYPE_SHORT_MAP } from 'features/parameters/types/constants';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import type { AnyModelConfig } from 'services/api/types';
type UseModelCustomSelectArg<T extends AnyModelConfig> = {
modelConfigs: T[];
isLoading: boolean;
selectedModel?: ModelIdentifierField | null;
onChange: (value: T | null) => void;
modelFilter?: (model: T) => boolean;
isModelDisabled?: (model: T) => boolean;
};
type UseModelCustomSelectReturn = {
selectedItem: Item | null;
items: Item[];
onChange: (item: Item | null) => void;
placeholder: string;
};
const modelFilterDefault = () => true;
const isModelDisabledDefault = () => false;
export const useModelCustomSelect = <T extends AnyModelConfig>({
modelConfigs,
isLoading,
selectedModel,
onChange,
modelFilter = modelFilterDefault,
isModelDisabled = isModelDisabledDefault,
}: UseModelCustomSelectArg<T>): UseModelCustomSelectReturn => {
const { t } = useTranslation();
const items: Item[] = useMemo(
() =>
modelConfigs.filter(modelFilter).map<Item>((m) => ({
label: m.name,
value: m.key,
description: m.description,
group: MODEL_TYPE_SHORT_MAP[m.base],
isDisabled: isModelDisabled(m),
})),
[modelConfigs, isModelDisabled, modelFilter]
);
const _onChange = useCallback(
(item: Item | null) => {
if (!item || !modelConfigs) {
return;
}
const model = modelConfigs.find((m) => m.key === item.value);
if (!model) {
return;
}
onChange(model);
},
[modelConfigs, onChange]
);
const selectedItem = useMemo(() => items.find((o) => o.value === selectedModel?.key) ?? null, [selectedModel, items]);
const placeholder = useMemo(() => {
if (isLoading) {
return t('common.loading');
}
if (items.length === 0) {
return t('models.noModelsAvailable');
}
return t('models.selectModel');
}, [isLoading, items, t]);
return {
items,
onChange: _onChange,
selectedItem,
placeholder,
};
};

View File

@ -1,10 +0,0 @@
import type { BaseModelType } from './types';
export const ALL_BASE_MODELS: BaseModelType[] = ['sd-1', 'sd-2', 'sdxl', 'sdxl-refiner'];
export const NON_REFINER_BASE_MODELS: BaseModelType[] = ['sd-1', 'sd-2', 'sdxl'];
export const SDXL_MAIN_MODELS: BaseModelType[] = ['sdxl'];
export const NON_SDXL_MAIN_MODELS: BaseModelType[] = ['sd-1', 'sd-2'];
export const REFINER_BASE_MODELS: BaseModelType[] = ['sdxl-refiner'];

View File

@ -6,7 +6,7 @@ import { $authToken } from 'app/store/nanostores/authToken';
import { $baseUrl } from 'app/store/nanostores/baseUrl'; import { $baseUrl } from 'app/store/nanostores/baseUrl';
import { $projectId } from 'app/store/nanostores/projectId'; import { $projectId } from 'app/store/nanostores/projectId';
export const tagTypes = [ const tagTypes = [
'AppVersion', 'AppVersion',
'AppConfig', 'AppConfig',
'Board', 'Board',

View File

@ -118,10 +118,6 @@ export const isTIModelConfig = (config: AnyModelConfig): config is MainModelConf
export type ModelInstallJob = S['ModelInstallJob']; export type ModelInstallJob = S['ModelInstallJob'];
export type ModelInstallStatus = S['InstallStatus']; export type ModelInstallStatus = S['InstallStatus'];
export type HFModelSource = S['HFModelSource'];
export type LocalModelSource = S['LocalModelSource'];
export type URLModelSource = S['URLModelSource'];
// Graphs // Graphs
export type Graph = S['Graph']; export type Graph = S['Graph'];
export type NonNullableGraph = O.Required<Graph, 'nodes' | 'edges'>; export type NonNullableGraph = O.Required<Graph, 'nodes' | 'edges'>;