MCPcopy Create free account
hub / github.com/Icecubesaad/OpenLLM-Studio / useModelDelete

Function useModelDelete

src/hooks/useModelDelete.ts:4–40  ·  view source on GitHub ↗
(onSuccess?: () => void)

Source from the content-addressed store, hash-verified

2import { deleteModel } from '../lib/tauri';
3
4export function useModelDelete(onSuccess?: () => void) {
5 const [isDeleting, setIsDeleting] = useState(false);
6 const [error, setError] = useState<string | null>(null);
7
8 const handleDeleteModel = async (modelName: string) => {
9 // Show confirmation dialog
10 const confirmed = window.confirm(
11 `Are you sure you want to delete ${modelName}? This action cannot be undone.`
12 );
13
14 if (!confirmed) {
15 return;
16 }
17
18 setIsDeleting(true);
19 setError(null);
20
21 try {
22 await deleteModel(modelName);
23 if (onSuccess) {
24 onSuccess();
25 }
26 } catch (err) {
27 const errorMessage = err instanceof Error ? err.message : 'Failed to delete model';
28 setError(errorMessage);
29 console.error('Failed to delete model:', err);
30 } finally {
31 setIsDeleting(false);
32 }
33 };
34
35 return {
36 deleteModel: handleDeleteModel,
37 isDeleting,
38 error,
39 };
40}

Callers 2

MyLibraryFunction · 0.90
ModelLibraryFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected