Add ability to join a room from a channel ID

co-authored-by: max <max@zed.dev>
This commit is contained in:
Mikayla Maki 2023-07-31 15:27:10 -07:00
parent 4b94bfa045
commit 92fa879b0c
No known key found for this signature in database
16 changed files with 485 additions and 105 deletions

View file

@ -5,7 +5,7 @@ use crate::{
AppState,
};
use anyhow::anyhow;
use call::ActiveCall;
use call::{ActiveCall, Room};
use client::{
self, proto::PeerId, ChannelStore, Client, Connection, Credentials, EstablishConnectionError,
UserStore,
@ -269,6 +269,44 @@ impl TestServer {
}
}
async fn make_channel(
&self,
channel: &str,
admin: (&TestClient, &mut TestAppContext),
members: &mut [(&TestClient, &mut TestAppContext)],
) -> u64 {
let (admin_client, admin_cx) = admin;
let channel_id = admin_client
.channel_store
.update(admin_cx, |channel_store, _| {
channel_store.create_channel(channel, None)
})
.await
.unwrap();
for (member_client, member_cx) in members {
admin_client
.channel_store
.update(admin_cx, |channel_store, _| {
channel_store.invite_member(channel_id, member_client.user_id().unwrap(), false)
})
.await
.unwrap();
admin_cx.foreground().run_until_parked();
member_client
.channel_store
.update(*member_cx, |channels, _| {
channels.respond_to_channel_invite(channel_id, true)
})
.await
.unwrap();
}
channel_id
}
async fn create_room(&self, clients: &mut [(&TestClient, &mut TestAppContext)]) {
self.make_contacts(clients).await;
@ -516,3 +554,27 @@ impl Drop for TestClient {
self.client.teardown();
}
}
#[derive(Debug, Eq, PartialEq)]
struct RoomParticipants {
remote: Vec<String>,
pending: Vec<String>,
}
fn room_participants(room: &ModelHandle<Room>, cx: &mut TestAppContext) -> RoomParticipants {
room.read_with(cx, |room, _| {
let mut remote = room
.remote_participants()
.iter()
.map(|(_, participant)| participant.user.github_login.clone())
.collect::<Vec<_>>();
let mut pending = room
.pending_participants()
.iter()
.map(|user| user.github_login.clone())
.collect::<Vec<_>>();
remote.sort();
pending.sort();
RoomParticipants { remote, pending }
})
}