Fix panic by disallowing multiple room joins (#3149)

Release Notes:

- Fixed panic that could occur when switching channels quickly
This commit is contained in:
Conrad Irwin 2023-10-24 23:57:08 +02:00 committed by GitHub
commit b8bd070a83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 240 additions and 34 deletions

View file

@ -1,7 +1,6 @@
use crate::{
call_settings::CallSettings,
participant::{LocalParticipant, ParticipantLocation, RemoteParticipant, RemoteVideoTrack},
IncomingCall,
};
use anyhow::{anyhow, Result};
use audio::{Audio, Sound};
@ -291,37 +290,32 @@ impl Room {
})
}
pub(crate) fn join_channel(
pub(crate) async fn join_channel(
channel_id: u64,
client: Arc<Client>,
user_store: ModelHandle<UserStore>,
cx: &mut AppContext,
) -> Task<Result<ModelHandle<Self>>> {
cx.spawn(|cx| async move {
Self::from_join_response(
client.request(proto::JoinChannel { channel_id }).await?,
client,
user_store,
cx,
)
})
cx: AsyncAppContext,
) -> Result<ModelHandle<Self>> {
Self::from_join_response(
client.request(proto::JoinChannel { channel_id }).await?,
client,
user_store,
cx,
)
}
pub(crate) fn join(
call: &IncomingCall,
pub(crate) async fn join(
room_id: u64,
client: Arc<Client>,
user_store: ModelHandle<UserStore>,
cx: &mut AppContext,
) -> Task<Result<ModelHandle<Self>>> {
let id = call.room_id;
cx.spawn(|cx| async move {
Self::from_join_response(
client.request(proto::JoinRoom { id }).await?,
client,
user_store,
cx,
)
})
cx: AsyncAppContext,
) -> Result<ModelHandle<Self>> {
Self::from_join_response(
client.request(proto::JoinRoom { id: room_id }).await?,
client,
user_store,
cx,
)
}
pub fn mute_on_join(cx: &AppContext) -> bool {