updated to use new import model mutation

This commit is contained in:
Jennifer Player 2024-02-27 09:48:41 -05:00
parent 175cfe41a4
commit 110b0bc8fe

View File

@ -16,7 +16,7 @@ import type { ChangeEventHandler } from 'react';
import { useCallback, useMemo, useState } from 'react'; import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { PiXBold } from 'react-icons/pi'; import { PiXBold } from 'react-icons/pi';
import { type ScanFolderResponse, useImportMainModelsMutation } from 'services/api/endpoints/models'; import { type ScanFolderResponse, useInstallModelMutation } from 'services/api/endpoints/models';
import { ScanModelResultItem } from './ScanModelResultItem'; import { ScanModelResultItem } from './ScanModelResultItem';
@ -29,7 +29,7 @@ export const ScanModelsResults = ({ results }: ScanModelResultsProps) => {
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const [importMainModel] = useImportMainModelsMutation(); const [installModel] = useInstallModelMutation();
const filteredResults = useMemo(() => { const filteredResults = useMemo(() => {
return results.filter((result) => { return results.filter((result) => {
@ -51,7 +51,7 @@ export const ScanModelsResults = ({ results }: ScanModelResultsProps) => {
if (result.is_installed) { if (result.is_installed) {
continue; continue;
} }
importMainModel({ source: result.path, config: undefined }) installModel({ source: result.path })
.unwrap() .unwrap()
.then((_) => { .then((_) => {
dispatch( dispatch(
@ -76,7 +76,7 @@ export const ScanModelsResults = ({ results }: ScanModelResultsProps) => {
} }
}); });
} }
}, [importMainModel, filteredResults, dispatch, t]); }, [installModel, filteredResults, dispatch, t]);
return ( return (
<> <>