diff --git a/Cargo.toml b/Cargo.toml index e508dfa..761fba5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ crossterm = { version = "0.27", features = ["event-stream"] } ratatui = { version = "0.26", features = ["serde"] } tui-input = "0.8" tui-tree-widget = "0.20" +throbber-widgets-tui = "0.5.0" # Config for 'cargo dist' [workspace.metadata.dist] diff --git a/rm-main/Cargo.toml b/rm-main/Cargo.toml index 8db88e1..e6311ea 100644 --- a/rm-main/Cargo.toml +++ b/rm-main/Cargo.toml @@ -29,4 +29,5 @@ crossterm.workspace = true ratatui.workspace = true tui-input.workspace = true tui-tree-widget.workspace = true -throbber-widgets-tui = "0.5.0" +throbber-widgets-tui.workspace = true + diff --git a/rm-main/src/app.rs b/rm-main/src/app.rs index 1b53232..fdb5ce0 100644 --- a/rm-main/src/app.rs +++ b/rm-main/src/app.rs @@ -82,13 +82,6 @@ impl App { let (tick_tx, tick_rx) = mpsc::unbounded_channel(); tokio::spawn(transmission::action_handler(ctx.clone(), trans_rx)); - tokio::spawn(async move { - let mut interval = tokio::time::interval(tokio::time::Duration::from_millis(250)); - loop { - let _ = tick_tx.send(Action::Tick); - interval.tick().await; - } - }); Ok(Self { should_quit: false, main_window: MainWindow::new(ctx.clone()), @@ -113,16 +106,15 @@ impl App { } async fn main_loop(&mut self, tui: &mut Tui) -> Result<()> { + let mut interval = tokio::time::interval(tokio::time::Duration::from_millis(250)); loop { let tui_event = tui.next(); let action = self.action_rx.recv(); - let tick_action = self.tick_rx.recv(); + let tick_action = interval.tick(); tokio::select! { - tick = tick_action => { - if let Some(_) = tick { - self.ctx.action_tx.send(Action::Tick).unwrap(); - } + _ = tick_action => { + self.ctx.action_tx.send(Action::Tick).unwrap(); }, event = tui_event => {