diff --git a/src/app.rs b/src/app.rs index 2a28bbd..5252cff 100644 --- a/src/app.rs +++ b/src/app.rs @@ -225,8 +225,8 @@ impl App { loop { let state = store.state_cloned().await; - if let Some(e) = tui.next().await { - match e { + for event in tui.next().await { + match event { tui::Event::Quit => tui_action_tx.send(TuiAction::Quit)?, tui::Event::Tick => tui_action_tx.send(TuiAction::Tick)?, tui::Event::Render => tui_action_tx.send(TuiAction::Render)?, @@ -239,10 +239,11 @@ impl App { _ => {} } for (_, component) in self.components.iter_mut() { - component.handle_events(&e, &state)?; + component.handle_events(&event, &state)?; } } + let mut rendered = false; while let Ok(action) = tui_action_rx.try_recv() { match action { TuiAction::Quit => self.should_quit = true, @@ -253,7 +254,10 @@ impl App { self.draw(&mut tui, &state)?; } TuiAction::Render => { - self.draw(&mut tui, &state)?; + if !rendered { + rendered = true; + self.draw(&mut tui, &state)?; + } } _ => {} } diff --git a/src/tui.rs b/src/tui.rs index 76b115c..c38078d 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -223,8 +223,10 @@ impl Tui { Ok(()) } - pub async fn next(&mut self) -> Option { - self.event_rx.recv().await + pub async fn next(&mut self) -> Vec { + let mut buffer: Vec = Vec::with_capacity(10000); + self.event_rx.recv_many(&mut buffer, 10000).await; + return buffer; } }