From 6f888f16307fb58a0b2cd0d94e0efc173c35164a Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 30 Jan 2026 01:37:48 +0300 Subject: [PATCH] fix(ui): Optimistic close for context menu actions --- frontend/src/components/context_menu.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/context_menu.rs b/frontend/src/components/context_menu.rs index d57419a..7c31e96 100644 --- a/frontend/src/components/context_menu.rs +++ b/frontend/src/components/context_menu.rs @@ -11,7 +11,9 @@ pub fn ContextMenu( let handle_action = move |action: &str| { let hash = torrent_hash.clone(); let action_str = action.to_string(); - let close = on_close.clone(); + + // Optimistic UI: Close immediately + on_close.call(()); spawn_local(async move { let body = serde_json::json!({ @@ -22,11 +24,9 @@ pub fn ContextMenu( let _ = Request::post("/api/torrents/action") .header("Content-Type", "application/json") .body(body.to_string()) - .unwrap() // Unwrap the Result + .unwrap() .send() .await; - - close.call(()); }); };