Skip to content

Commit

Permalink
feat: config refresh timings
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden committed Jun 27, 2024
1 parent 96cc5ea commit 1142a7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions rm-config/defaults/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ beginner_mode = true
# If enabled, hides header row of torrents tab
headers_hide = false

torrents_refresh = 5
stats_refresh = 10
free_space_refresh = 10

[connection]
url = "http://CHANGE_ME:9091/transmission/rpc" # REQUIRED!

Expand Down
6 changes: 6 additions & 0 deletions rm-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub struct General {
pub beginner_mode: bool,
#[serde(default)]
pub headers_hide: bool,
#[serde(default)]
pub torrents_refresh: u64,
#[serde(default)]
pub stats_refresh: u64,
#[serde(default)]
pub free_space_refresh: u64,
}

fn default_accent_color() -> Color {
Expand Down
6 changes: 3 additions & 3 deletions rm-main/src/transmission/fetchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn stats(ctx: app::Ctx, stats: Arc<Mutex<Option<SessionStats>>>) {
.arguments;
*stats.lock().unwrap() = Some(new_stats);
ctx.send_action(Action::Render);
tokio::time::sleep(Duration::from_secs(5)).await;
tokio::time::sleep(Duration::from_secs(ctx.config.general.stats_refresh)).await;
}
}

Expand All @@ -50,7 +50,7 @@ pub async fn free_space(ctx: app::Ctx, free_space: Arc<Mutex<Option<FreeSpace>>>
.arguments;
*free_space.lock().unwrap() = Some(new_free_space);
ctx.send_action(Action::Render);
tokio::time::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(ctx.config.general.free_space_refresh)).await;
}
}

Expand Down Expand Up @@ -85,6 +85,6 @@ pub async fn torrents(ctx: app::Ctx, table_manager: Arc<Mutex<TableManager>>) {
.set_new_rows(new_torrents.iter().map(RustmissionTorrent::from).collect());
}
ctx.send_action(Action::Render);
tokio::time::sleep(Duration::from_secs(5)).await;
tokio::time::sleep(Duration::from_secs(ctx.config.general.torrents_refresh)).await;
}
}

0 comments on commit 1142a7f

Please sign in to comment.