Compare commits
2 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab27cf3eb4 | ||
|
|
7b4c9ff336 |
@@ -85,7 +85,10 @@ fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl In
|
|||||||
let f_idx = file.index;
|
let f_idx = file.index;
|
||||||
let path_clone = file.path.clone();
|
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();
|
let (h, idx, p) = req.clone();
|
||||||
async move {
|
async move {
|
||||||
let res = shared::server_fns::torrent::set_file_priority(h, idx, p).await;
|
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));
|
crate::store::show_toast(shared::NotificationLevel::Error, format!("Öncelik değiştirilemedi: {:?}", e));
|
||||||
} else {
|
} else {
|
||||||
crate::store::show_toast(shared::NotificationLevel::Success, "Dosya önceliği güncellendi.".to_string());
|
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
|
res
|
||||||
}
|
}
|
||||||
@@ -102,7 +107,6 @@ fn FileRow(file: TorrentFile, hash: String, on_refresh: Callback<()>) -> impl In
|
|||||||
<FileContextMenu
|
<FileContextMenu
|
||||||
torrent_hash=hash
|
torrent_hash=hash
|
||||||
file_index=f_idx
|
file_index=f_idx
|
||||||
on_refresh=on_refresh
|
|
||||||
set_priority=set_priority
|
set_priority=set_priority
|
||||||
>
|
>
|
||||||
<TableRow class="hover:bg-muted/50 transition-colors group">
|
<TableRow class="hover:bg-muted/50 transition-colors group">
|
||||||
@@ -136,7 +140,6 @@ fn FileContextMenu(
|
|||||||
children: Children,
|
children: Children,
|
||||||
torrent_hash: String,
|
torrent_hash: String,
|
||||||
file_index: u32,
|
file_index: u32,
|
||||||
on_refresh: Callback<()>,
|
|
||||||
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
|
set_priority: Action<(String, u32, u8), Result<(), ServerFnError>>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let hash_c1 = torrent_hash.clone();
|
let hash_c1 = torrent_hash.clone();
|
||||||
@@ -155,10 +158,8 @@ fn FileContextMenu(
|
|||||||
<ContextMenuItem on:click={
|
<ContextMenuItem on:click={
|
||||||
let h = hash_c1;
|
let h = hash_c1;
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
let ra = on_refresh.clone();
|
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 2));
|
sp.dispatch((h.clone(), file_index, 2));
|
||||||
ra.run(());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
@@ -169,10 +170,8 @@ fn FileContextMenu(
|
|||||||
<ContextMenuItem on:click={
|
<ContextMenuItem on:click={
|
||||||
let h = hash_c2;
|
let h = hash_c2;
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
let ra = on_refresh.clone();
|
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 1));
|
sp.dispatch((h.clone(), file_index, 1));
|
||||||
ra.run(());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
@@ -183,10 +182,8 @@ fn FileContextMenu(
|
|||||||
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
|
<ContextMenuItem class="text-destructive focus:bg-destructive/10" on:click={
|
||||||
let h = hash_c3;
|
let h = hash_c3;
|
||||||
let sp = set_priority.clone();
|
let sp = set_priority.clone();
|
||||||
let ra = on_refresh.clone();
|
|
||||||
move |_| {
|
move |_| {
|
||||||
sp.dispatch((h.clone(), file_index, 0));
|
sp.dispatch((h.clone(), file_index, 0));
|
||||||
ra.run(());
|
|
||||||
crate::components::ui::context_menu::close_context_menu();
|
crate::components::ui::context_menu::close_context_menu();
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ pub async fn set_file_priority(
|
|||||||
];
|
];
|
||||||
|
|
||||||
client
|
client
|
||||||
.call("f.set_priority", ¶ms)
|
.call("f.priority.set", ¶ms)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?;
|
.map_err(|e| ServerFnError::new(format!("RPC error setting priority: {}", e)))?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user