diff --git a/frontend/src/components/torrent/files.rs b/frontend/src/components/torrent/files.rs
index 6daeb9b..4dc45f7 100644
--- a/frontend/src/components/torrent/files.rs
+++ b/frontend/src/components/torrent/files.rs
@@ -15,10 +15,9 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
|h| async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
);
- // Refresh action
- let refresh_files = Action::new(|h: &String| {
- let h = h.clone();
- async move { shared::server_fns::torrent::get_files(h).await.unwrap_or_default() }
+ // Callback to trigger a refetch — safe, doesn't destroy existing components
+ let on_refresh = Callback::new(move |_: ()| {
+ files_resource.refetch();
});
let stored_hash = StoredValue::new(hash);
@@ -26,10 +25,7 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
view! {
}>
{move || {
- let files = match refresh_files.value().get() {
- Some(f) => f,
- None => files_resource.get().unwrap_or_default(),
- };
+ let files = files_resource.get().unwrap_or_default();
if files.is_empty() {
return view! {
@@ -61,12 +57,11 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
key=|f| f.index
children={move |f| {
let p_hash = stored_hash.get_value();
- let r_files = refresh_files.clone();
view! {
}
}}
@@ -86,7 +81,7 @@ pub fn TorrentFilesTab(hash: String) -> impl IntoView {
}
#[component]
-fn FileRow(file: TorrentFile, hash: String, refresh_action: Action>) -> impl IntoView {
+fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl IntoView {
let f_idx = file.index;
let path_clone = file.path.clone();
@@ -107,7 +102,7 @@ fn FileRow(file: TorrentFile, hash: String, refresh_action: Action
@@ -141,7 +136,7 @@ fn FileContextMenu(
children: Children,
torrent_hash: String,
file_index: u32,
- refresh_action: Action>,
+ on_refresh: Callback<()>,
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
) -> impl IntoView {
let hash_c1 = torrent_hash.clone();
@@ -159,11 +154,11 @@ fn FileContextMenu(
@@ -173,11 +168,11 @@ fn FileContextMenu(
@@ -187,11 +182,11 @@ fn FileContextMenu(