mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-31 21:36:26 +00:00
Following face piles finally take their first breath
This commit is contained in:
parent
4ffc8cd9fd
commit
4513c40993
3 changed files with 21 additions and 18 deletions
|
@ -459,10 +459,10 @@ impl Room {
|
||||||
self.participant_user_ids.contains(&user_id)
|
self.participant_user_ids.contains(&user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn follows(&self, leader_id: PeerId) -> Option<&[PeerId]> {
|
pub fn follows(&self, leader_id: PeerId) -> &[PeerId] {
|
||||||
self.follows_by_leader_id
|
self.follows_by_leader_id
|
||||||
.get(&leader_id)
|
.get(&leader_id)
|
||||||
.map(|v| v.as_slice())
|
.map_or(&[], |v| v.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_room_updated(
|
async fn handle_room_updated(
|
||||||
|
|
|
@ -1996,7 +1996,7 @@ impl Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drop(db_projects);
|
drop(db_projects);
|
||||||
|
|
||||||
let mut db_followers = db_room.find_related(follower::Entity).stream(tx).await?;
|
let mut db_followers = db_room.find_related(follower::Entity).stream(tx).await?;
|
||||||
|
|
|
@ -510,7 +510,8 @@ impl CollabTitlebarItem {
|
||||||
Some(self.render_face_pile(
|
Some(self.render_face_pile(
|
||||||
&user,
|
&user,
|
||||||
replica_id,
|
replica_id,
|
||||||
Some((participant.peer_id, participant.location)),
|
participant.peer_id,
|
||||||
|
Some(participant.location),
|
||||||
workspace,
|
workspace,
|
||||||
theme,
|
theme,
|
||||||
cx,
|
cx,
|
||||||
|
@ -530,9 +531,18 @@ impl CollabTitlebarItem {
|
||||||
) -> Option<ElementBox> {
|
) -> Option<ElementBox> {
|
||||||
let user = workspace.read(cx).user_store().read(cx).current_user();
|
let user = workspace.read(cx).user_store().read(cx).current_user();
|
||||||
let replica_id = workspace.read(cx).project().read(cx).replica_id();
|
let replica_id = workspace.read(cx).project().read(cx).replica_id();
|
||||||
|
let peer_id = workspace.read(cx).client().peer_id()?;
|
||||||
let status = *workspace.read(cx).client().status().borrow();
|
let status = *workspace.read(cx).client().status().borrow();
|
||||||
if let Some(user) = user {
|
if let Some(user) = user {
|
||||||
Some(self.render_face_pile(&user, Some(replica_id), None, workspace, theme, cx))
|
Some(self.render_face_pile(
|
||||||
|
&user,
|
||||||
|
Some(replica_id),
|
||||||
|
peer_id,
|
||||||
|
None,
|
||||||
|
workspace,
|
||||||
|
theme,
|
||||||
|
cx,
|
||||||
|
))
|
||||||
} else if matches!(status, client::Status::UpgradeRequired) {
|
} else if matches!(status, client::Status::UpgradeRequired) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -560,17 +570,16 @@ impl CollabTitlebarItem {
|
||||||
&self,
|
&self,
|
||||||
user: &User,
|
user: &User,
|
||||||
replica_id: Option<ReplicaId>,
|
replica_id: Option<ReplicaId>,
|
||||||
peer_id_and_location: Option<(PeerId, ParticipantLocation)>,
|
peer_id: PeerId,
|
||||||
|
location: Option<ParticipantLocation>,
|
||||||
workspace: &ViewHandle<Workspace>,
|
workspace: &ViewHandle<Workspace>,
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
cx: &mut RenderContext<Self>,
|
cx: &mut RenderContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
let is_followed = peer_id_and_location.map_or(false, |(peer_id, _)| {
|
let is_followed = workspace.read(cx).is_following(peer_id);
|
||||||
workspace.read(cx).is_following(peer_id)
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut avatar_style;
|
let mut avatar_style;
|
||||||
if let Some((_, location)) = peer_id_and_location {
|
if let Some(location) = location {
|
||||||
if let ParticipantLocation::SharedProject { project_id } = location {
|
if let ParticipantLocation::SharedProject { project_id } = location {
|
||||||
if Some(project_id) == workspace.read(cx).project().read(cx).remote_id() {
|
if Some(project_id) == workspace.read(cx).project().read(cx).remote_id() {
|
||||||
avatar_style = theme.workspace.titlebar.avatar;
|
avatar_style = theme.workspace.titlebar.avatar;
|
||||||
|
@ -599,11 +608,8 @@ impl CollabTitlebarItem {
|
||||||
.with_child(Self::render_face(avatar.clone(), avatar_style, theme))
|
.with_child(Self::render_face(avatar.clone(), avatar_style, theme))
|
||||||
.with_children(
|
.with_children(
|
||||||
(|| {
|
(|| {
|
||||||
let peer_id_and_location = peer_id_and_location?;
|
|
||||||
let peer_id = peer_id_and_location.0;
|
|
||||||
|
|
||||||
let room = ActiveCall::global(cx).read(cx).room()?.read(cx);
|
let room = ActiveCall::global(cx).read(cx).room()?.read(cx);
|
||||||
let followers = room.follows(peer_id)?;
|
let followers = room.follows(peer_id);
|
||||||
|
|
||||||
Some(followers.into_iter().flat_map(|&follower| {
|
Some(followers.into_iter().flat_map(|&follower| {
|
||||||
let participant = room.remote_participant_for_peer_id(follower)?;
|
let participant = room.remote_participant_for_peer_id(follower)?;
|
||||||
|
@ -614,7 +620,6 @@ impl CollabTitlebarItem {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten(),
|
.flatten(),
|
||||||
)
|
)
|
||||||
.with_reversed_paint_order()
|
|
||||||
.boxed()
|
.boxed()
|
||||||
}))
|
}))
|
||||||
.with_children(replica_color.map(|replica_color| {
|
.with_children(replica_color.map(|replica_color| {
|
||||||
|
@ -626,13 +631,11 @@ impl CollabTitlebarItem {
|
||||||
.bottom()
|
.bottom()
|
||||||
.boxed()
|
.boxed()
|
||||||
}))
|
}))
|
||||||
.constrained()
|
|
||||||
.with_width(theme.workspace.titlebar.avatar_width)
|
|
||||||
.contained()
|
.contained()
|
||||||
.with_margin_left(theme.workspace.titlebar.avatar_margin)
|
.with_margin_left(theme.workspace.titlebar.avatar_margin)
|
||||||
.boxed();
|
.boxed();
|
||||||
|
|
||||||
if let Some((peer_id, location)) = peer_id_and_location {
|
if let Some(location) = location {
|
||||||
if let Some(replica_id) = replica_id {
|
if let Some(replica_id) = replica_id {
|
||||||
MouseEventHandler::<ToggleFollow>::new(replica_id.into(), cx, move |_, _| content)
|
MouseEventHandler::<ToggleFollow>::new(replica_id.into(), cx, move |_, _| content)
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
|
Loading…
Reference in a new issue