diff --git a/src/main.rs b/src/main.rs index 4655d33..0e628f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,6 +69,7 @@ enum CurrentScreen { Main, Sending, Receiving, + Stopping, } impl App { @@ -84,8 +85,8 @@ impl App { loop { terminal.draw(|frame| self.draw(frame))?; self.handle_events().await?; - let rstate = self.state.running_state.lock().await; - if *rstate == RunningState::Stopping { + + if self.screen == CurrentScreen::Stopping { break; } 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.screen = CurrentScreen::Stopping; } async fn send(&mut self) {