mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 06:33:52 +03:00
Limit number of collaborators in local Facepiles
This commit is contained in:
parent
26a3f68080
commit
8be798d1c0
@ -3,7 +3,7 @@ use auto_update::AutoUpdateStatus;
|
|||||||
use call::{ActiveCall, ParticipantLocation, Room};
|
use call::{ActiveCall, ParticipantLocation, Room};
|
||||||
use client::{proto::PeerId, Client, User, UserStore};
|
use client::{proto::PeerId, Client, User, UserStore};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, canvas, div, point, px, rems, Action, AnyElement, AppContext, Element, Hsla,
|
actions, canvas, div, point, px, Action, AnyElement, AppContext, Element, Hsla,
|
||||||
InteractiveElement, IntoElement, Model, ParentElement, Path, Render,
|
InteractiveElement, IntoElement, Model, ParentElement, Path, Render,
|
||||||
StatefulInteractiveElement, Styled, Subscription, View, ViewContext, VisualContext, WeakView,
|
StatefulInteractiveElement, Styled, Subscription, View, ViewContext, VisualContext, WeakView,
|
||||||
WindowBounds,
|
WindowBounds,
|
||||||
@ -480,7 +480,9 @@ impl CollabTitlebarItem {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FACEPILE_LIMIT: usize = 3;
|
||||||
let followers = project_id.map_or(&[] as &[_], |id| room.followers_for(peer_id, id));
|
let followers = project_id.map_or(&[] as &[_], |id| room.followers_for(peer_id, id));
|
||||||
|
let extra_count = followers.len().saturating_sub(FACEPILE_LIMIT);
|
||||||
|
|
||||||
let pile = FacePile::default()
|
let pile = FacePile::default()
|
||||||
.child(
|
.child(
|
||||||
@ -502,18 +504,34 @@ impl CollabTitlebarItem {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.children(followers.iter().filter_map(|follower_peer_id| {
|
.children(
|
||||||
let follower = room
|
followers
|
||||||
.remote_participants()
|
.iter()
|
||||||
.values()
|
.take(FACEPILE_LIMIT)
|
||||||
.find_map(|p| (p.peer_id == *follower_peer_id).then_some(&p.user))
|
.filter_map(|follower_peer_id| {
|
||||||
.or_else(|| {
|
let follower = room
|
||||||
(self.client.peer_id() == Some(*follower_peer_id)).then_some(current_user)
|
.remote_participants()
|
||||||
})?
|
.values()
|
||||||
.clone();
|
.find_map(|p| (p.peer_id == *follower_peer_id).then_some(&p.user))
|
||||||
|
.or_else(|| {
|
||||||
|
(self.client.peer_id() == Some(*follower_peer_id))
|
||||||
|
.then_some(current_user)
|
||||||
|
})?
|
||||||
|
.clone();
|
||||||
|
|
||||||
Some(Avatar::new(follower.avatar_uri.clone()))
|
Some(Avatar::new(follower.avatar_uri.clone()))
|
||||||
}));
|
}),
|
||||||
|
)
|
||||||
|
.children(if extra_count > 0 {
|
||||||
|
Some(
|
||||||
|
div()
|
||||||
|
.ml_1()
|
||||||
|
.child(Label::new(format!("+{extra_count}")))
|
||||||
|
.into_any_element(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
});
|
||||||
|
|
||||||
Some(pile)
|
Some(pile)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user