From 560d8a8004bc8614268d30640887ed486df0be9f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 7 Oct 2022 14:52:39 +0200 Subject: [PATCH] Don't leave the room if there's a pending room update --- crates/call/src/room.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 21e7c85c7fced3579324c9426a0bc89362a7d59e..41648e6b24f323ce40a04fffd4af5ccc4d11d30c 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -26,7 +26,7 @@ pub struct Room { client: Arc, user_store: ModelHandle, subscriptions: Vec, - _pending_room_update: Option>, + pending_room_update: Option>, } impl Entity for Room { @@ -67,7 +67,7 @@ impl Room { pending_call_count: 0, subscriptions: vec![client.add_message_handler(cx.handle(), Self::handle_room_updated)], leave_when_empty: false, - _pending_room_update: None, + pending_room_update: None, client, user_store, } @@ -130,6 +130,7 @@ impl Room { fn should_leave(&self) -> bool { self.leave_when_empty + && self.pending_room_update.is_none() && self.pending_users.is_empty() && self.remote_participants.is_empty() && self.pending_call_count == 0 @@ -197,7 +198,7 @@ impl Room { user_store.get_users(room.pending_user_ids, cx), ) }); - self._pending_room_update = Some(cx.spawn(|this, mut cx| async move { + self.pending_room_update = Some(cx.spawn(|this, mut cx| async move { let (participants, pending_users) = futures::join!(participants, pending_users); this.update(&mut cx, |this, cx| { @@ -249,6 +250,7 @@ impl Room { cx.notify(); } + this.pending_room_update.take(); if this.should_leave() { let _ = this.leave(cx); }