fix: the fields for trigger checking

This commit is contained in:
jialin
2025-04-03 18:08:43 +08:00
parent 939f46c7e6
commit b6136a092d
22 changed files with 226 additions and 73 deletions
@@ -61,6 +61,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
];
const [isEvaluating, setIsEvaluating] = useState<boolean>(false);
const [current, setCurrent] = useState<string>('');
const currentRef = useRef<string>('');
const cacheRepoOptions = useRef<any[]>([]);
const axiosTokenRef = useRef<any>(null);
const checkTokenRef = useRef<any>(null);
@@ -100,6 +101,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
const handleOnSelectModel = (item: any) => {
onSelectModel(item);
setCurrent(item.id);
currentRef.current = item.id;
};
// huggeface
@@ -222,7 +224,12 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
repoOptions: resultList
};
});
handleOnSelectModel(resultList[0]);
const currentItem = resultList.find(
(item) => item.id === currentRef.current
);
if (currentItem) {
handleOnSelectModel(currentItem);
}
} catch (error) {
setIsEvaluating(false);
}
@@ -264,9 +271,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
handleOnSelectModel(list[0]);
setLoadingModel?.(false);
timer.current = setTimeout(() => {
handleEvaluate(list);
}, 200);
handleEvaluate(list);
} catch (error: any) {
setDataSource({
repoOptions: [],