Compare commits
2 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1370db6ce | ||
|
|
1432dec828 |
@@ -359,6 +359,14 @@ async fn main() {
|
||||
let mut backoff_duration = Duration::from_secs(1);
|
||||
|
||||
loop {
|
||||
// Determine polling interval based on active clients
|
||||
let active_clients = event_bus_tx.receiver_count();
|
||||
let loop_interval = if active_clients > 0 {
|
||||
Duration::from_secs(1)
|
||||
} else {
|
||||
Duration::from_secs(30)
|
||||
};
|
||||
|
||||
// 1. Fetch Torrents
|
||||
let torrents_result = sse::fetch_torrents(&client).await;
|
||||
|
||||
@@ -429,6 +437,9 @@ async fn main() {
|
||||
}
|
||||
|
||||
previous_torrents = new_torrents;
|
||||
|
||||
// Success case: sleep for the determined interval
|
||||
tokio::time::sleep(loop_interval).await;
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Error fetching torrents in background: {}", e);
|
||||
@@ -449,20 +460,15 @@ async fn main() {
|
||||
"Backoff: Sleeping for {:?} due to rTorrent error.",
|
||||
backoff_duration
|
||||
);
|
||||
|
||||
tokio::time::sleep(backoff_duration).await;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Stats
|
||||
match stats_result {
|
||||
Ok(stats) => {
|
||||
let _ = event_bus_tx.send(AppEvent::Stats(stats));
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("Error fetching global stats: {}", e);
|
||||
}
|
||||
if let Ok(stats) = stats_result {
|
||||
let _ = event_bus_tx.send(AppEvent::Stats(stats));
|
||||
}
|
||||
|
||||
tokio::time::sleep(backoff_duration).await;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ pub fn TorrentTable() -> impl IntoView {
|
||||
<div class="flex items-center">"Status" {move || sort_arrow(SortColumn::Status)}</div>
|
||||
</th>
|
||||
<th class="w-24 cursor-pointer hover:bg-base-300 group select-none" on:click=move |_| handle_sort(SortColumn::DownSpeed)>
|
||||
<div class="flex items-center">"Down Speed" {move || sort_arrow(SortColumn::DownSpeed)}</div>
|
||||
<div class="flex items-center">"DL Speed" {move || sort_arrow(SortColumn::DownSpeed)}</div>
|
||||
</th>
|
||||
<th class="w-24 cursor-pointer hover:bg-base-300 group select-none" on:click=move |_| handle_sort(SortColumn::UpSpeed)>
|
||||
<div class="flex items-center">"Up Speed" {move || sort_arrow(SortColumn::UpSpeed)}</div>
|
||||
@@ -345,7 +345,7 @@ pub fn TorrentTable() -> impl IntoView {
|
||||
(SortColumn::Size, "Size"),
|
||||
(SortColumn::Progress, "Progress"),
|
||||
(SortColumn::Status, "Status"),
|
||||
(SortColumn::DownSpeed, "Down Speed"),
|
||||
(SortColumn::DownSpeed, "DL Speed"),
|
||||
(SortColumn::UpSpeed, "Up Speed"),
|
||||
(SortColumn::ETA, "ETA"),
|
||||
(SortColumn::AddedDate, "Date"),
|
||||
|
||||
Reference in New Issue
Block a user