fix(ui): Optimistic close for context menu actions
This commit is contained in:
@@ -11,7 +11,9 @@ pub fn ContextMenu(
|
|||||||
let handle_action = move |action: &str| {
|
let handle_action = move |action: &str| {
|
||||||
let hash = torrent_hash.clone();
|
let hash = torrent_hash.clone();
|
||||||
let action_str = action.to_string();
|
let action_str = action.to_string();
|
||||||
let close = on_close.clone();
|
|
||||||
|
// Optimistic UI: Close immediately
|
||||||
|
on_close.call(());
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let body = serde_json::json!({
|
let body = serde_json::json!({
|
||||||
@@ -22,11 +24,9 @@ pub fn ContextMenu(
|
|||||||
let _ = Request::post("/api/torrents/action")
|
let _ = Request::post("/api/torrents/action")
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.body(body.to_string())
|
.body(body.to_string())
|
||||||
.unwrap() // Unwrap the Result<RequestBuilder, JsValue>
|
.unwrap()
|
||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
close.call(());
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user