Move Participant and ParticipantLocation down into client crate
This commit is contained in:
parent
be56f775d4
commit
9ec697390d
8 changed files with 62 additions and 72 deletions
|
@ -1,5 +1,4 @@
|
||||||
pub mod call_settings;
|
pub mod call_settings;
|
||||||
pub mod participant;
|
|
||||||
pub mod room;
|
pub mod room;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
@ -19,7 +18,6 @@ use settings::Settings;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub use live_kit_client::{Frame, RemoteAudioTrack, RemoteVideoTrack};
|
pub use live_kit_client::{Frame, RemoteAudioTrack, RemoteVideoTrack};
|
||||||
pub use participant::ParticipantLocation;
|
|
||||||
pub use room::Room;
|
pub use room::Room;
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
|
pub fn init(client: Arc<Client>, user_store: Model<UserStore>, cx: &mut AppContext) {
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
use anyhow::{anyhow, Result};
|
|
||||||
use client::ParticipantIndex;
|
|
||||||
use client::{proto, User};
|
|
||||||
use gpui::WeakModel;
|
|
||||||
use project::Project;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
|
||||||
pub enum ParticipantLocation {
|
|
||||||
SharedProject { project_id: u64 },
|
|
||||||
UnsharedProject,
|
|
||||||
External,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ParticipantLocation {
|
|
||||||
pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
|
|
||||||
match location.and_then(|l| l.variant) {
|
|
||||||
Some(proto::participant_location::Variant::SharedProject(project)) => {
|
|
||||||
Ok(Self::SharedProject {
|
|
||||||
project_id: project.id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Some(proto::participant_location::Variant::UnsharedProject(_)) => {
|
|
||||||
Ok(Self::UnsharedProject)
|
|
||||||
}
|
|
||||||
Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
|
|
||||||
None => Err(anyhow!("participant location was not provided")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
|
||||||
pub struct LocalParticipant {
|
|
||||||
pub projects: Vec<proto::ParticipantProject>,
|
|
||||||
pub active_project: Option<WeakModel<Project>>,
|
|
||||||
pub role: proto::ChannelRole,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct RemoteParticipant {
|
|
||||||
pub user: Arc<User>,
|
|
||||||
pub peer_id: proto::PeerId,
|
|
||||||
pub role: proto::ChannelRole,
|
|
||||||
pub projects: Vec<proto::ParticipantProject>,
|
|
||||||
pub location: ParticipantLocation,
|
|
||||||
pub participant_index: ParticipantIndex,
|
|
||||||
pub muted: bool,
|
|
||||||
pub speaking: bool,
|
|
||||||
}
|
|
|
@ -1,12 +1,9 @@
|
||||||
use crate::{
|
use crate::call_settings::CallSettings;
|
||||||
call_settings::CallSettings,
|
|
||||||
participant::{LocalParticipant, ParticipantLocation, RemoteParticipant},
|
|
||||||
};
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use audio::{Audio, Sound};
|
use audio::{Audio, Sound};
|
||||||
use client::{
|
use client::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, ParticipantIndex, TypedEnvelope, User, UserStore,
|
Client, Participant, ParticipantIndex, ParticipantLocation, TypedEnvelope, User, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{BTreeMap, HashMap, HashSet};
|
use collections::{BTreeMap, HashMap, HashSet};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
|
@ -63,7 +60,7 @@ pub struct Room {
|
||||||
shared_projects: HashSet<WeakModel<Project>>,
|
shared_projects: HashSet<WeakModel<Project>>,
|
||||||
joined_projects: HashSet<WeakModel<Project>>,
|
joined_projects: HashSet<WeakModel<Project>>,
|
||||||
local_participant: LocalParticipant,
|
local_participant: LocalParticipant,
|
||||||
remote_participants: BTreeMap<u64, RemoteParticipant>,
|
remote_participants: BTreeMap<u64, Participant>,
|
||||||
remote_audio_tracks: BTreeMap<u64, HashMap<String, Arc<RemoteAudioTrack>>>,
|
remote_audio_tracks: BTreeMap<u64, HashMap<String, Arc<RemoteAudioTrack>>>,
|
||||||
remote_video_tracks: BTreeMap<u64, HashMap<String, Arc<RemoteVideoTrack>>>,
|
remote_video_tracks: BTreeMap<u64, HashMap<String, Arc<RemoteVideoTrack>>>,
|
||||||
pending_participants: Vec<Arc<User>>,
|
pending_participants: Vec<Arc<User>>,
|
||||||
|
@ -81,6 +78,13 @@ pub struct Room {
|
||||||
maintain_connection: Option<Task<Option<()>>>,
|
maintain_connection: Option<Task<Option<()>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Default)]
|
||||||
|
pub struct LocalParticipant {
|
||||||
|
pub projects: Vec<proto::ParticipantProject>,
|
||||||
|
pub active_project: Option<WeakModel<Project>>,
|
||||||
|
pub role: proto::ChannelRole,
|
||||||
|
}
|
||||||
|
|
||||||
impl EventEmitter<Event> for Room {}
|
impl EventEmitter<Event> for Room {}
|
||||||
|
|
||||||
impl Room {
|
impl Room {
|
||||||
|
@ -604,11 +608,11 @@ impl Room {
|
||||||
&self.local_participant
|
&self.local_participant
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remote_participants(&self) -> &BTreeMap<u64, RemoteParticipant> {
|
pub fn remote_participants(&self) -> &BTreeMap<u64, Participant> {
|
||||||
&self.remote_participants
|
&self.remote_participants
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remote_participant_for_peer_id(&self, peer_id: PeerId) -> Option<&RemoteParticipant> {
|
pub fn remote_participant_for_peer_id(&self, peer_id: PeerId) -> Option<&Participant> {
|
||||||
self.remote_participants
|
self.remote_participants
|
||||||
.values()
|
.values()
|
||||||
.find(|p| p.peer_id == peer_id)
|
.find(|p| p.peer_id == peer_id)
|
||||||
|
@ -824,7 +828,7 @@ impl Room {
|
||||||
} else {
|
} else {
|
||||||
this.remote_participants.insert(
|
this.remote_participants.insert(
|
||||||
participant.user_id,
|
participant.user_id,
|
||||||
RemoteParticipant {
|
Participant {
|
||||||
user: user.clone(),
|
user: user.clone(),
|
||||||
participant_index,
|
participant_index,
|
||||||
peer_id,
|
peer_id,
|
||||||
|
|
|
@ -29,6 +29,25 @@ pub struct Collaborator {
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Participant {
|
||||||
|
pub user: Arc<User>,
|
||||||
|
pub peer_id: proto::PeerId,
|
||||||
|
pub role: proto::ChannelRole,
|
||||||
|
pub projects: Vec<proto::ParticipantProject>,
|
||||||
|
pub location: ParticipantLocation,
|
||||||
|
pub participant_index: ParticipantIndex,
|
||||||
|
pub muted: bool,
|
||||||
|
pub speaking: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub enum ParticipantLocation {
|
||||||
|
SharedProject { project_id: u64 },
|
||||||
|
UnsharedProject,
|
||||||
|
External,
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialOrd for User {
|
impl PartialOrd for User {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
Some(self.cmp(other))
|
Some(self.cmp(other))
|
||||||
|
@ -692,3 +711,20 @@ impl Collaborator {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ParticipantLocation {
|
||||||
|
pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
|
||||||
|
match location.and_then(|l| l.variant) {
|
||||||
|
Some(proto::participant_location::Variant::SharedProject(project)) => {
|
||||||
|
Ok(Self::SharedProject {
|
||||||
|
project_id: project.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Some(proto::participant_location::Variant::UnsharedProject(_)) => {
|
||||||
|
Ok(Self::UnsharedProject)
|
||||||
|
}
|
||||||
|
Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
|
||||||
|
None => Err(anyhow!("participant location was not provided")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ use crate::{
|
||||||
rpc::{CLEANUP_TIMEOUT, RECONNECT_TIMEOUT},
|
rpc::{CLEANUP_TIMEOUT, RECONNECT_TIMEOUT},
|
||||||
tests::{channel_id, room_participants, RoomParticipants, TestClient, TestServer},
|
tests::{channel_id, room_participants, RoomParticipants, TestClient, TestServer},
|
||||||
};
|
};
|
||||||
use call::{room, ActiveCall, ParticipantLocation, Room};
|
use call::{room, ActiveCall, Room};
|
||||||
use client::{User, RECEIVE_TIMEOUT};
|
use client::{ParticipantLocation, User, RECEIVE_TIMEOUT};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions};
|
use fs::{repository::GitFileStatus, FakeFs, Fs as _, RemoveOptions};
|
||||||
use futures::StreamExt as _;
|
use futures::StreamExt as _;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::face_pile::FacePile;
|
use crate::face_pile::FacePile;
|
||||||
use auto_update::AutoUpdateStatus;
|
use auto_update::AutoUpdateStatus;
|
||||||
use call::{ActiveCall, ParticipantLocation, Room};
|
use call::{ActiveCall, Room};
|
||||||
use client::{proto::PeerId, Client, ParticipantIndex, User, UserStore};
|
use client::{proto::PeerId, Client, ParticipantIndex, ParticipantLocation, User, UserStore};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, canvas, div, point, px, rems, Action, AnyElement, AppContext, Element, Hsla,
|
actions, canvas, div, point, px, rems, Action, AnyElement, AppContext, Element, Hsla,
|
||||||
InteractiveElement, IntoElement, Model, ParentElement, Path, Render,
|
InteractiveElement, IntoElement, Model, ParentElement, Path, Render,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{pane_group::element::pane_axis, AppState, FollowerState, Pane, Workspace};
|
use crate::{pane_group::element::pane_axis, AppState, FollowerState, Pane, Workspace};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use call::{ActiveCall, ParticipantLocation};
|
use call::ActiveCall;
|
||||||
|
use client::ParticipantLocation;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
point, size, AnyWeakView, Axis, Bounds, Entity as _, IntoElement, Model, Pixels, Point, View,
|
point, size, AnyWeakView, Axis, Bounds, Entity as _, IntoElement, Model, Pixels, Point, View,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use anyhow::{anyhow, Context as _, Result};
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{
|
use client::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, Status, TypedEnvelope, UserStore,
|
Client, ParticipantLocation, Status, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
||||||
|
@ -2398,9 +2398,9 @@ impl Workspace {
|
||||||
let project = self.project.read(cx);
|
let project = self.project.read(cx);
|
||||||
|
|
||||||
let other_project_id = match remote_participant.location {
|
let other_project_id = match remote_participant.location {
|
||||||
call::ParticipantLocation::External => None,
|
ParticipantLocation::External => None,
|
||||||
call::ParticipantLocation::UnsharedProject => None,
|
ParticipantLocation::UnsharedProject => None,
|
||||||
call::ParticipantLocation::SharedProject { project_id } => {
|
ParticipantLocation::SharedProject { project_id } => {
|
||||||
if Some(project_id) == project.remote_id() {
|
if Some(project_id) == project.remote_id() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -2789,15 +2789,15 @@ impl Workspace {
|
||||||
let leader_in_this_app;
|
let leader_in_this_app;
|
||||||
let leader_in_this_project;
|
let leader_in_this_project;
|
||||||
match participant.location {
|
match participant.location {
|
||||||
call::ParticipantLocation::SharedProject { project_id } => {
|
ParticipantLocation::SharedProject { project_id } => {
|
||||||
leader_in_this_app = true;
|
leader_in_this_app = true;
|
||||||
leader_in_this_project = Some(project_id) == self.project.read(cx).remote_id();
|
leader_in_this_project = Some(project_id) == self.project.read(cx).remote_id();
|
||||||
}
|
}
|
||||||
call::ParticipantLocation::UnsharedProject => {
|
ParticipantLocation::UnsharedProject => {
|
||||||
leader_in_this_app = true;
|
leader_in_this_app = true;
|
||||||
leader_in_this_project = false;
|
leader_in_this_project = false;
|
||||||
}
|
}
|
||||||
call::ParticipantLocation::External => {
|
ParticipantLocation::External => {
|
||||||
leader_in_this_app = false;
|
leader_in_this_app = false;
|
||||||
leader_in_this_project = false;
|
leader_in_this_project = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue