Skip to content

Commit 7c3eb06

Browse files
fix: Scan again not refetching the model list
1 parent 715e321 commit 7c3eb06

File tree

1 file changed

+29
-8
lines changed
  • invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/AddModelsPanel

1 file changed

+29
-8
lines changed

invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/AddModelsPanel/SearchFolderForm.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import IAIInput from 'common/components/IAIInput';
77
import { memo, useCallback } from 'react';
88
import { useTranslation } from 'react-i18next';
99
import { FaSearch, FaSync, FaTrash } from 'react-icons/fa';
10+
import { useGetModelsInFolderQuery } from 'services/api/endpoints/models';
1011
import {
1112
setAdvancedAddScanModel,
1213
setSearchFolder,
@@ -24,6 +25,10 @@ function SearchFolderForm() {
2425
(state: RootState) => state.modelmanager.searchFolder
2526
);
2627

28+
const { refetch: refetchFoundModels } = useGetModelsInFolderQuery({
29+
search_path: searchFolder ? searchFolder : '',
30+
});
31+
2732
const searchFolderForm = useForm<SearchFolderForm>({
2833
initialValues: {
2934
folder: '',
@@ -37,6 +42,10 @@ function SearchFolderForm() {
3742
[dispatch]
3843
);
3944

45+
const scanAgainHandler = () => {
46+
refetchFoundModels();
47+
};
48+
4049
return (
4150
<form
4251
onSubmit={searchFolderForm.onSubmit((values) =>
@@ -89,14 +98,26 @@ function SearchFolderForm() {
8998
</Flex>
9099

91100
<Flex gap={2}>
92-
<IAIIconButton
93-
aria-label={t('modelManager.scanAgain')}
94-
tooltip={t('modelManager.scanAgain')}
95-
icon={!searchFolder ? <FaSearch /> : <FaSync />}
96-
fontSize={18}
97-
size="sm"
98-
type="submit"
99-
/>
101+
{!searchFolder ? (
102+
<IAIIconButton
103+
aria-label={t('modelManager.findModels')}
104+
tooltip={t('modelManager.findModels')}
105+
icon={<FaSearch />}
106+
fontSize={18}
107+
size="sm"
108+
type="submit"
109+
/>
110+
) : (
111+
<IAIIconButton
112+
aria-label={t('modelManager.scanAgain')}
113+
tooltip={t('modelManager.scanAgain')}
114+
icon={<FaSync />}
115+
onClick={scanAgainHandler}
116+
fontSize={18}
117+
size="sm"
118+
/>
119+
)}
120+
100121
<IAIIconButton
101122
aria-label={t('modelManager.clearCheckpointFolder')}
102123
tooltip={t('modelManager.clearCheckpointFolder')}

0 commit comments

Comments
 (0)