From 69f6c96b700b9fde5578ae204992a67986d456ab Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:24:46 +0000 Subject: [PATCH] refactor: remove input_poll_rate from Ui, instead use const POLL_RATE --- src/ui/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 4d22d86..fc3244c 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -37,11 +37,11 @@ use crate::{ }; pub const ORANGE: ratatui::style::Color = ratatui::style::Color::Rgb(255, 178, 36); +const POLL_RATE: Duration = std::time::Duration::from_millis(100); pub struct Ui { app_data: Arc>, gui_state: Arc>, - input_poll_rate: Duration, input_tx: Sender, is_running: Arc, now: Instant, @@ -75,7 +75,6 @@ impl Ui { app_data, cursor_position, gui_state, - input_poll_rate: std::time::Duration::from_millis(100), input_tx, is_running, now: Instant::now(), @@ -145,7 +144,7 @@ impl Ui { Ok(()) } - /// Use exeternal docker cli to exec into a container + /// Use external docker cli to exec into a container async fn exec(&mut self) { let exec_mode = self.gui_state.lock().get_exec_mode(); @@ -181,7 +180,7 @@ impl Ui { return Err(AppError::Terminal); } - if crossterm::event::poll(self.input_poll_rate).unwrap_or(false) { + if crossterm::event::poll(POLL_RATE).unwrap_or(false) { if let Ok(event) = event::read() { if let Event::Key(key) = event { if key.kind == event::KeyEventKind::Press { @@ -221,7 +220,7 @@ impl Ui { } } -/// Frequent data required by multiple framde drawing functions, can reduce mutex reads by placing it all in here +/// Frequent data required by multiple frame drawing functions, can reduce mutex reads by placing it all in here #[derive(Debug, Clone)] pub struct FrameData { chart_data: Option<(CpuTuple, MemTuple)>,