diff --git a/rm-config/defaults/config.toml b/rm-config/defaults/config.toml index d0f6256..e81956a 100644 --- a/rm-config/defaults/config.toml +++ b/rm-config/defaults/config.toml @@ -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! diff --git a/rm-config/src/lib.rs b/rm-config/src/lib.rs index d6f0f11..ad65a03 100644 --- a/rm-config/src/lib.rs +++ b/rm-config/src/lib.rs @@ -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 { diff --git a/rm-main/src/transmission/fetchers.rs b/rm-main/src/transmission/fetchers.rs index db98d4e..5ade9a4 100644 --- a/rm-main/src/transmission/fetchers.rs +++ b/rm-main/src/transmission/fetchers.rs @@ -23,7 +23,7 @@ pub async fn stats(ctx: app::Ctx, stats: Arc>>) { .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; } } @@ -50,7 +50,7 @@ pub async fn free_space(ctx: app::Ctx, free_space: Arc>> .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; } } @@ -85,6 +85,6 @@ pub async fn torrents(ctx: app::Ctx, table_manager: Arc>) { .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; } }