From 2201e04e15758ab5303f652373321ba69db6dc71 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 20 Aug 2022 23:18:07 +0200 Subject: [PATCH] Fix UI not updating when connecting to room fails --- src/euph/room.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/euph/room.rs b/src/euph/room.rs index 88b3e0c..7ceaada 100644 --- a/src/euph/room.rs +++ b/src/euph/room.rs @@ -30,6 +30,7 @@ pub enum EuphRoomEvent { Connected, Disconnected, Packet(Box), + Stopped, } #[derive(Debug)] @@ -77,6 +78,11 @@ impl State { if let Err(e) = result { error!("e&{name}: {}", e); } + + // Ensure that whoever is using this room knows that it's gone. + // Otherwise, the users of the Room may be left in an inconsistent or + // outdated state, and the UI may not update correctly. + let _ = euph_room_event_tx.send(EuphRoomEvent::Stopped); } async fn reconnect( @@ -98,6 +104,7 @@ impl State { event_tx.send(Event::Disconnected)?; } else { info!("e&{}: could not connect", name); + event_tx.send(Event::Disconnected)?; } tokio::time::sleep(Duration::from_secs(5)).await; // TODO Make configurable }