Assign unique color indices to room participants, use those instead of replica_ids
Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
parent
7711530704
commit
545b5e0161
35 changed files with 707 additions and 639 deletions
|
@ -31,6 +31,7 @@ language = { path = "../language" }
|
|||
media = { path = "../media" }
|
||||
project = { path = "../project" }
|
||||
settings = { path = "../settings" }
|
||||
theme = { path = "../theme" }
|
||||
util = { path = "../util" }
|
||||
|
||||
anyhow.workspace = true
|
||||
|
|
|
@ -6,6 +6,7 @@ pub use live_kit_client::Frame;
|
|||
use live_kit_client::RemoteAudioTrack;
|
||||
use project::Project;
|
||||
use std::{fmt, sync::Arc};
|
||||
use theme::ColorIndex;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ParticipantLocation {
|
||||
|
@ -43,6 +44,7 @@ pub struct RemoteParticipant {
|
|||
pub peer_id: proto::PeerId,
|
||||
pub projects: Vec<proto::ParticipantProject>,
|
||||
pub location: ParticipantLocation,
|
||||
pub color_index: ColorIndex,
|
||||
pub muted: bool,
|
||||
pub speaking: bool,
|
||||
pub video_tracks: HashMap<live_kit_client::Sid, Arc<RemoteVideoTrack>>,
|
||||
|
|
|
@ -21,6 +21,7 @@ use live_kit_client::{
|
|||
use postage::stream::Stream;
|
||||
use project::Project;
|
||||
use std::{future::Future, mem, pin::Pin, sync::Arc, time::Duration};
|
||||
use theme::ColorIndex;
|
||||
use util::{post_inc, ResultExt, TryFutureExt};
|
||||
|
||||
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
|
@ -714,6 +715,7 @@ impl Room {
|
|||
participant.user_id,
|
||||
RemoteParticipant {
|
||||
user: user.clone(),
|
||||
color_index: ColorIndex(participant.color_index),
|
||||
peer_id,
|
||||
projects: participant.projects,
|
||||
location,
|
||||
|
@ -807,6 +809,15 @@ impl Room {
|
|||
let _ = this.leave(cx);
|
||||
}
|
||||
|
||||
this.user_store.update(cx, |user_store, cx| {
|
||||
let color_indices_by_user_id = this
|
||||
.remote_participants
|
||||
.iter()
|
||||
.map(|(user_id, participant)| (*user_id, participant.color_index))
|
||||
.collect();
|
||||
user_store.set_color_indices(color_indices_by_user_id, cx);
|
||||
});
|
||||
|
||||
this.check_invariants();
|
||||
cx.notify();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue