diff --git a/src/ui.rs b/src/ui.rs
index 75558a4f..1038ddd0 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -13,7 +13,7 @@ use std::time::Duration;
use termion::raw::RawTerminal;
use tokio::sync::broadcast;
-use tokio::sync::mpsc::{self, UnboundedReceiver};
+use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
use super::event::Event;
use super::store::State;
@@ -32,14 +32,21 @@ pub struct Frontend {
}
impl Frontend {
- pub fn new() -> (Self, UnboundedReceiver) {
+ pub fn new() -> (Self, UnboundedSender, UnboundedReceiver) {
let (action_tx, action_rx) = mpsc::unbounded_channel();
- (Self { action_tx }, action_rx)
+ (
+ Self {
+ action_tx: action_tx.clone(),
+ },
+ action_tx,
+ action_rx,
+ )
}
pub async fn main_loop(
self,
+ root: Option,
mut state_rx: UnboundedReceiver,
mut interrupt_rx: broadcast::Receiver>,
) -> anyhow::Result>
@@ -56,7 +63,13 @@ impl Frontend {
let mut root = {
let state = state_rx.recv().await.unwrap();
- W::new(&state, self.action_tx.clone())
+ match root {
+ Some(mut root) => {
+ root.update(&state);
+ root
+ }
+ None => W::new(&state, self.action_tx.clone()),
+ }
};
let result: anyhow::Result> = loop {