|
1 | 1 | import { Box, Flex, Heading, Tab, TabList, TabPanel, TabPanels, Tabs } from '@invoke-ai/ui-library';
|
| 2 | +import { useStore } from '@nanostores/react'; |
2 | 3 | import { StarterModelsForm } from 'features/modelManagerV2/subpanels/AddModelPanel/StarterModels/StarterModelsForm';
|
3 |
| -import { useMemo } from 'react'; |
| 4 | +import { atom } from 'nanostores'; |
| 5 | +import { useCallback } from 'react'; |
4 | 6 | import { useTranslation } from 'react-i18next';
|
5 |
| -import { useMainModels } from 'services/api/hooks/modelsByType'; |
6 | 7 |
|
7 | 8 | import { HuggingFaceForm } from './AddModelPanel/HuggingFaceFolder/HuggingFaceForm';
|
8 | 9 | import { InstallModelForm } from './AddModelPanel/InstallModelForm';
|
9 | 10 | import { ModelInstallQueue } from './AddModelPanel/ModelInstallQueue/ModelInstallQueue';
|
10 | 11 | import { ScanModelsForm } from './AddModelPanel/ScanFolder/ScanFolderForm';
|
11 | 12 |
|
| 13 | +export const $installModelsTab = atom(0); |
| 14 | + |
12 | 15 | export const InstallModels = () => {
|
13 | 16 | const { t } = useTranslation();
|
14 |
| - const [mainModels, { data }] = useMainModels(); |
15 |
| - const defaultIndex = useMemo(() => { |
16 |
| - if (data && mainModels.length) { |
17 |
| - return 0; |
18 |
| - } |
19 |
| - return 3; |
20 |
| - }, [data, mainModels.length]); |
| 17 | + const index = useStore($installModelsTab); |
| 18 | + const onChange = useCallback((index: number) => { |
| 19 | + $installModelsTab.set(index); |
| 20 | + }, []); |
21 | 21 |
|
22 | 22 | return (
|
23 | 23 | <Flex layerStyle="first" borderRadius="base" w="full" h="full" flexDir="column" gap={4}>
|
24 | 24 | <Heading fontSize="xl">{t('modelManager.addModel')}</Heading>
|
25 |
| - <Tabs variant="collapse" height="50%" display="flex" flexDir="column" defaultIndex={defaultIndex}> |
| 25 | + <Tabs variant="collapse" height="50%" display="flex" flexDir="column" index={index} onChange={onChange}> |
26 | 26 | <TabList>
|
27 | 27 | <Tab>{t('modelManager.urlOrLocalPath')}</Tab>
|
28 | 28 | <Tab>{t('modelManager.huggingFace')}</Tab>
|
|
0 commit comments