diff --git a/frontend/src/components/torrent/files.rs b/frontend/src/components/torrent/files.rs index 4dc45f7..4b9ce7f 100644 --- a/frontend/src/components/torrent/files.rs +++ b/frontend/src/components/torrent/files.rs @@ -85,7 +85,10 @@ fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl In let f_idx = file.index; let path_clone = file.path.clone(); - let set_priority = Action::new(|req: &(String, u32, u8)| { + // on_refresh is called AFTER the server responds, not before + let on_refresh_stored = StoredValue::new(on_refresh); + + let set_priority = Action::new(move |req: &(String, u32, u8)| { let (h, idx, p) = req.clone(); async move { let res = shared::server_fns::torrent::set_file_priority(h, idx, p).await; @@ -93,6 +96,8 @@ fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl In crate::store::show_toast(shared::NotificationLevel::Error, format!("Öncelik değiştirilemedi: {:?}", e)); } else { crate::store::show_toast(shared::NotificationLevel::Success, "Dosya önceliği güncellendi.".to_string()); + // Refetch AFTER the server has saved the priority + on_refresh_stored.get_value().run(()); } res } @@ -102,7 +107,6 @@ fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl In @@ -136,7 +140,6 @@ fn FileContextMenu( children: Children, torrent_hash: String, file_index: u32, - on_refresh: Callback<()>, set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>, ) -> impl IntoView { let hash_c1 = torrent_hash.clone(); @@ -155,10 +158,8 @@ fn FileContextMenu( @@ -169,10 +170,8 @@ fn FileContextMenu( @@ -183,10 +182,8 @@ fn FileContextMenu(