Abuse a closure instead of abusing options/iterators quite so much
This commit is contained in:
parent
58c41778e7
commit
33c265d3cf
2 changed files with 17 additions and 32 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) -> &[PeerId] {
|
pub fn follows(&self, leader_id: PeerId) -> Option<&[PeerId]> {
|
||||||
self.follows_by_leader_id
|
self.follows_by_leader_id
|
||||||
.get(&leader_id)
|
.get(&leader_id)
|
||||||
.map_or(&[], |v| v.as_slice())
|
.map(|v| v.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_room_updated(
|
async fn handle_room_updated(
|
||||||
|
|
|
@ -569,11 +569,6 @@ impl CollabTitlebarItem {
|
||||||
workspace.read(cx).is_following(peer_id)
|
workspace.read(cx).is_following(peer_id)
|
||||||
});
|
});
|
||||||
|
|
||||||
let room = ActiveCall::global(cx).read(cx).room();
|
|
||||||
let get_followers = |leader_id: PeerId| -> &[PeerId] {
|
|
||||||
room.map_or(&[], |room| room.read(cx).follows(leader_id))
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut avatar_style;
|
let mut avatar_style;
|
||||||
if let Some((_, location)) = peer_id_and_location {
|
if let Some((_, location)) = peer_id_and_location {
|
||||||
if let ParticipantLocation::SharedProject { project_id } = location {
|
if let ParticipantLocation::SharedProject { project_id } = location {
|
||||||
|
@ -603,31 +598,21 @@ impl CollabTitlebarItem {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(Self::render_face(avatar.clone(), avatar_style, theme))
|
.with_child(Self::render_face(avatar.clone(), avatar_style, theme))
|
||||||
.with_children(
|
.with_children(
|
||||||
peer_id_and_location
|
(|| {
|
||||||
.map(|(peer_id, _)| {
|
let peer_id_and_location = peer_id_and_location?;
|
||||||
get_followers(peer_id)
|
let peer_id = peer_id_and_location.0;
|
||||||
.into_iter()
|
|
||||||
.map(|&follower| {
|
let room = ActiveCall::global(cx).read(cx).room()?.read(cx);
|
||||||
room.map(|room| {
|
let followers = room.follows(peer_id)?;
|
||||||
room.read(cx)
|
|
||||||
.remote_participant_for_peer_id(follower)
|
Some(followers.into_iter().flat_map(|&follower| {
|
||||||
.map(|participant| {
|
let participant = room.remote_participant_for_peer_id(follower)?;
|
||||||
participant.user.avatar.as_ref().map(|avatar| {
|
let avatar = participant.user.avatar.as_ref()?;
|
||||||
Self::render_face(
|
Some(Self::render_face(avatar.clone(), avatar_style, theme))
|
||||||
avatar.clone(),
|
}))
|
||||||
avatar_style,
|
})()
|
||||||
theme,
|
.into_iter()
|
||||||
)
|
.flatten(),
|
||||||
})
|
|
||||||
})
|
|
||||||
.flatten()
|
|
||||||
})
|
|
||||||
.flatten()
|
|
||||||
})
|
|
||||||
.flatten()
|
|
||||||
})
|
|
||||||
.into_iter()
|
|
||||||
.flatten(),
|
|
||||||
)
|
)
|
||||||
.with_reversed_paint_order()
|
.with_reversed_paint_order()
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue