fix: Scan again not refetching the model list

This commit is contained in:
blessedcoolant 2023-07-18 12:44:16 +12:00
parent 715e3217d0
commit 7c3eb06a71

View File

@ -7,6 +7,7 @@ import IAIInput from 'common/components/IAIInput';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FaSearch, FaSync, FaTrash } from 'react-icons/fa'; import { FaSearch, FaSync, FaTrash } from 'react-icons/fa';
import { useGetModelsInFolderQuery } from 'services/api/endpoints/models';
import { import {
setAdvancedAddScanModel, setAdvancedAddScanModel,
setSearchFolder, setSearchFolder,
@ -24,6 +25,10 @@ function SearchFolderForm() {
(state: RootState) => state.modelmanager.searchFolder (state: RootState) => state.modelmanager.searchFolder
); );
const { refetch: refetchFoundModels } = useGetModelsInFolderQuery({
search_path: searchFolder ? searchFolder : '',
});
const searchFolderForm = useForm<SearchFolderForm>({ const searchFolderForm = useForm<SearchFolderForm>({
initialValues: { initialValues: {
folder: '', folder: '',
@ -37,6 +42,10 @@ function SearchFolderForm() {
[dispatch] [dispatch]
); );
const scanAgainHandler = () => {
refetchFoundModels();
};
return ( return (
<form <form
onSubmit={searchFolderForm.onSubmit((values) => onSubmit={searchFolderForm.onSubmit((values) =>
@ -89,14 +98,26 @@ function SearchFolderForm() {
</Flex> </Flex>
<Flex gap={2}> <Flex gap={2}>
<IAIIconButton {!searchFolder ? (
aria-label={t('modelManager.scanAgain')} <IAIIconButton
tooltip={t('modelManager.scanAgain')} aria-label={t('modelManager.findModels')}
icon={!searchFolder ? <FaSearch /> : <FaSync />} tooltip={t('modelManager.findModels')}
fontSize={18} icon={<FaSearch />}
size="sm" fontSize={18}
type="submit" size="sm"
/> type="submit"
/>
) : (
<IAIIconButton
aria-label={t('modelManager.scanAgain')}
tooltip={t('modelManager.scanAgain')}
icon={<FaSync />}
onClick={scanAgainHandler}
fontSize={18}
size="sm"
/>
)}
<IAIIconButton <IAIIconButton
aria-label={t('modelManager.clearCheckpointFolder')} aria-label={t('modelManager.clearCheckpointFolder')}
tooltip={t('modelManager.clearCheckpointFolder')} tooltip={t('modelManager.clearCheckpointFolder')}