diff options
| author | 2026-03-29 21:32:54 +0800 | |
|---|---|---|
| committer | 2026-03-29 21:32:54 +0800 | |
| commit | 5b799a125a970e5e56f29a08b3c86450855fb6c4 (patch) | |
| tree | 0467ce21983865b189f7daa9fe293faf04a149f2 /packages/ui/src/models | |
| parent | ffbfce895c37e8e8306d426a2e59e73647ed6a86 (diff) | |
| download | DropOut-5b799a125a970e5e56f29a08b3c86450855fb6c4.tar.gz DropOut-5b799a125a970e5e56f29a08b3c86450855fb6c4.zip | |
refactor(ui): rewrite instance create
Diffstat (limited to 'packages/ui/src/models')
| -rw-r--r-- | packages/ui/src/models/instance.ts | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/packages/ui/src/models/instance.ts b/packages/ui/src/models/instance.ts index 2f338b5..8c108c1 100644 --- a/packages/ui/src/models/instance.ts +++ b/packages/ui/src/models/instance.ts @@ -20,7 +20,7 @@ interface InstanceState { activeInstance: Instance | null; refresh: () => Promise<void>; - create: (name: string) => Promise<Instance | null>; + create: (name: string) => Promise<Instance>; delete: (id: string) => Promise<void>; update: (instance: Instance) => Promise<void>; setActiveInstance: (instance: Instance) => Promise<void>; @@ -64,17 +64,11 @@ export const useInstanceStore = create<InstanceState>((set, get) => ({ create: async (name) => { const { refresh } = get(); - try { - const instance = await createInstance(name); - await setActiveInstanceCommand(instance.id); - await refresh(); - toast.success(`Instance "${name}" created successfully`); - return instance; - } catch (e) { - console.error("Failed to create instance:", e); - toast.error(String(e)); - return null; - } + const instance = await createInstance(name); + await setActiveInstanceCommand(instance.id); + await refresh(); + toast.success(`Instance "${name}" created successfully`); + return instance; }, delete: async (id) => { |