From 3d467a949178022f29a9876be23a2bcb42318141 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 7 Oct 2022 09:23:25 +0200 Subject: [PATCH] Unset room on active call when disconnecting --- crates/call/src/call.rs | 8 +++++++- crates/collab/src/integration_tests.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs index 8617b5391a..01787023be 100644 --- a/crates/call/src/call.rs +++ b/crates/call/src/call.rs @@ -210,7 +210,13 @@ impl ActiveCall { if room.as_ref() != self.room.as_ref().map(|room| &room.0) { if let Some(room) = room { let subscriptions = vec![ - cx.observe(&room, |_, _, cx| cx.notify()), + cx.observe(&room, |this, room, cx| { + if room.read(cx).status().is_offline() { + this.set_room(None, cx); + } + + cx.notify(); + }), cx.subscribe(&room, |_, _, event, cx| cx.emit(event.clone())), ]; self.room = Some((room, subscriptions)); diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index 0767ee5ddb..665a9ca729 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -385,6 +385,7 @@ async fn test_leaving_room_on_disconnection( server.disconnect_client(client_a.current_user_id(cx_a)); cx_a.foreground().advance_clock(rpc::RECEIVE_TIMEOUT); + active_call_a.read_with(cx_a, |call, _| assert!(call.room().is_none())); assert_eq!( room_participants(&room_a, cx_a), RoomParticipants {