tiny tidy

This commit is contained in:
Joe Ardent 2025-07-15 17:28:40 -07:00
parent 75677faeae
commit 3e112d1cb6
2 changed files with 27 additions and 25 deletions

View file

@ -45,7 +45,7 @@ impl App {
}
#[tokio::main]
pub async fn run(
pub async fn start_and_run(
&mut self,
terminal: &mut DefaultTerminal,
config: Config,
@ -141,29 +141,6 @@ impl App {
}
}
async fn shutdown(handles: &mut JoinSet<Listeners>) {
let mut alarm = tokio::time::interval(tokio::time::Duration::from_secs(5));
alarm.tick().await;
loop {
tokio::select! {
join_result = handles.join_next() => {
match join_result {
Some(handle) => match handle {
Ok(h) => println!("Stopped {h:?}"),
Err(e) => println!("Got error {e:?}"),
}
None => break,
}
}
_ = alarm.tick() => {
println!("Exit timeout reached, aborting all unjoined tasks");
handles.abort_all();
break;
},
}
}
}
impl Widget for &App {
fn render(self, area: Rect, buf: &mut Buffer) {
let title = Line::from(" Joecalsend ".bold());
@ -194,3 +171,26 @@ impl Widget for &App {
.render(area, buf);
}
}
async fn shutdown(handles: &mut JoinSet<Listeners>) {
let mut alarm = tokio::time::interval(tokio::time::Duration::from_secs(5));
alarm.tick().await;
loop {
tokio::select! {
join_result = handles.join_next() => {
match join_result {
Some(handle) => match handle {
Ok(h) => println!("Stopped {h:?}"),
Err(e) => println!("Got error {e:?}"),
}
None => break,
}
}
_ = alarm.tick() => {
println!("Exit timeout reached, aborting all unjoined tasks");
handles.abort_all();
break;
},
}
}
}

View file

@ -35,5 +35,7 @@ fn main() -> error::Result<()> {
let mut app = App::new();
Ok(ratatui::run(|terminal| app.run(terminal, config, device))?)
Ok(ratatui::run(|terminal| {
app.start_and_run(terminal, config, device)
})?)
}