Skip to content

Commit

Permalink
Be more efficient about how we find room members.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulak committed May 13, 2023
1 parent 60fb762 commit 756372f
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/widgets/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,23 +528,19 @@ impl Chat {
members.push(member);
}

if members.len() > 5 {
if members.len() > 5 || members.len() == self.members.len() {
break;
}
}

let names: Vec<&str> = members
.iter()
.map(|m| {
m.display_name()
.unwrap_or_else(|| m.user_id().localpart())
.split_whitespace()
.next()
.unwrap_or_default()
})
.collect();

let iter = names.into_iter().map(|n| n.to_string());
let iter = members.iter().map(|m| {
m.display_name()
.unwrap_or_else(|| m.user_id().localpart())
.split_whitespace()
.next()
.unwrap_or_default()
.to_string()
});

pretty_list(limit_list(iter, 5, self.members.len(), Some("at least")))
})
Expand Down

0 comments on commit 756372f

Please sign in to comment.