stop on internal app state

This commit is contained in:
Joe Ardent 2025-07-08 14:02:57 -07:00
parent 1995aaa858
commit c32b0d289e

View file

@ -69,6 +69,7 @@ enum CurrentScreen {
Main, Main,
Sending, Sending,
Receiving, Receiving,
Stopping,
} }
impl App { impl App {
@ -84,8 +85,8 @@ impl App {
loop { loop {
terminal.draw(|frame| self.draw(frame))?; terminal.draw(|frame| self.draw(frame))?;
self.handle_events().await?; self.handle_events().await?;
let rstate = self.state.running_state.lock().await;
if *rstate == RunningState::Stopping { if self.screen == CurrentScreen::Stopping {
break; break;
} }
let peers = self.state.peers.lock().await; let peers = self.state.peers.lock().await;
@ -126,8 +127,9 @@ impl App {
} }
} }
async fn exit(&self) { async fn exit(&mut self) {
self.state.stop().await; self.state.stop().await;
self.screen = CurrentScreen::Stopping;
} }
async fn send(&mut self) { async fn send(&mut self) {