fix: do not get the backend when local path blur
This commit is contained in:
@@ -79,10 +79,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const updateShowWarning = () => {
|
||||
const backend = form.current?.getFieldValue?.('backend');
|
||||
const updateShowWarning = (backend: string) => {
|
||||
const localPath = form.current?.getFieldValue?.('local_path');
|
||||
|
||||
console.log('upateShowWarning', backend, localPath);
|
||||
|
||||
if (source !== modelSourceMap.local_path_value || !localPath) {
|
||||
return;
|
||||
}
|
||||
@@ -116,7 +117,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
if (backend === backendOptionsMap.llamaBox) {
|
||||
setIsGGUF(true);
|
||||
}
|
||||
updateShowWarning();
|
||||
updateShowWarning(backend);
|
||||
};
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
|
||||
@@ -95,8 +95,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const updateShowWarning = () => {
|
||||
const backend = form.getFieldValue?.('backend');
|
||||
const updateShowWarning = (backend: string) => {
|
||||
const localPath = form.getFieldValue?.('local_path');
|
||||
|
||||
if (formData?.source !== modelSourceMap.local_path_value || !localPath) {
|
||||
@@ -133,7 +132,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
form.setFieldValue('backend_version', '');
|
||||
handleSetGPUIds(val);
|
||||
updateShowWarning();
|
||||
updateShowWarning(backend);
|
||||
};
|
||||
|
||||
const handleOnFocus = () => {
|
||||
|
||||
@@ -176,21 +176,26 @@ const Models: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const createModelsChunkRequest = useCallback(async () => {
|
||||
chunkRequedtRef.current?.current?.cancel?.();
|
||||
try {
|
||||
const query = {
|
||||
search: queryParams.search,
|
||||
categories: queryParams.categories
|
||||
};
|
||||
chunkRequedtRef.current = setChunkRequest({
|
||||
url: `${MODELS_API}?${qs.stringify(_.pickBy(query, (val: any) => !!val))}`,
|
||||
handler: updateHandler
|
||||
});
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
}, [queryParams.categories, queryParams.search]);
|
||||
const createModelsChunkRequest = useCallback(
|
||||
async (params?: { search: string; categories: any[] }) => {
|
||||
const search = params?.search || queryParams.search;
|
||||
const categories = params?.categories || queryParams.categories;
|
||||
chunkRequedtRef.current?.current?.cancel?.();
|
||||
try {
|
||||
const query = {
|
||||
search: search,
|
||||
categories: categories
|
||||
};
|
||||
chunkRequedtRef.current = setChunkRequest({
|
||||
url: `${MODELS_API}?${qs.stringify(_.pickBy(query, (val: any) => !!val))}`,
|
||||
handler: updateHandler
|
||||
});
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
},
|
||||
[queryParams.categories, queryParams.search]
|
||||
);
|
||||
|
||||
const createModelsInstanceChunkRequest = useCallback(async () => {
|
||||
chunkInstanceRequedtRef.current?.current?.cancel?.();
|
||||
@@ -241,6 +246,10 @@ const Models: React.FC = () => {
|
||||
search: e.target.value
|
||||
}
|
||||
});
|
||||
createModelsChunkRequest({
|
||||
search: e.target.value,
|
||||
categories: queryParams.categories
|
||||
});
|
||||
}, 350);
|
||||
|
||||
const handleNameChange = useCallback(debounceUpdateFilter, [queryParams]);
|
||||
@@ -259,6 +268,10 @@ const Models: React.FC = () => {
|
||||
categories: value
|
||||
}
|
||||
});
|
||||
createModelsChunkRequest({
|
||||
search: queryParams.search,
|
||||
categories: value
|
||||
});
|
||||
},
|
||||
[queryParams]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user