forge
Explore
Log in

Don't you dare go Hollow

Room header voice pill puts whoever is speaking first and shows +N past three faces

Browse files at this commit

b1995a064e1df74063b4d10ca32fb549333ca5e8Ahmet Kaan GümüşParent: cf2498f
  • style
    • room header voice pill puts whoever is speaking first and shows +N past three faces
Show full message
💄 style: room header voice pill puts whoever is speaking first and shows +N past three faces
crates/client/src/gui/chat.rsmodified+16 -4
@@ -106,6 +106,8 @@ enum History {
106 End,106 End,
107 }107 }
108 108
109+const FACES: usize = 3;
110+
109 impl History {111 impl History {
110 fn of_page(length: usize) -> Self {112 fn of_page(length: usize) -> Self {
111 if length < MESSAGE_PAGE_LIMIT {113 if length < MESSAGE_PAGE_LIMIT {
@@ -2769,11 +2771,13 @@ impl Yumush {
2769 }2771 }
2770 2772
2771 let t = palette.tokens;2773 let t = palette.tokens;
2772- let users = self.voice_users(community_id);2774+ let mut users = self.voice_users(community_id);
2775+ users.sort_by_key(|user| !self.chat.waves.speaking.contains(&user.id));
2773 let speaker = users2776 let speaker = users
2774- .iter()2777+ .first()
2775 .map(|user| user.id)2778 .map(|user| user.id)
2776- .find(|id| self.chat.waves.speaking.contains(id));2779+ .filter(|id| self.chat.waves.speaking.contains(id));
2780+ let more = users.len().saturating_sub(FACES);
2777 let (icon, label) = match (direct, in_voice) {2781 let (icon, label) = match (direct, in_voice) {
2778 (true, false) => (IconName::Phone, w().chat.call),2782 (true, false) => (IconName::Phone, w().chat.call),
2779 (true, true) => (IconName::PhoneOff, w().chat.hang_up),2783 (true, true) => (IconName::PhoneOff, w().chat.hang_up),
@@ -2821,7 +2825,7 @@ impl Yumush {
2821 .h(px(space::LG))2825 .h(px(space::LG))
2822 .child(super::parts::voice_line(bands, voice, t)),2826 .child(super::parts::voice_line(bands, voice, t)),
2823 )2827 )
2824- .children(users.iter().take(3).enumerate().map(|(index, user)| {2828+ .children(users.iter().take(FACES).enumerate().map(|(index, user)| {
2825 avatar(2829 avatar(
2826 palette,2830 palette,
2827 user,2831 user,
@@ -2831,6 +2835,14 @@ impl Yumush {
2831 )2835 )
2832 .when(index > 0, |avatar| avatar.ml(px(-space::XS)))2836 .when(index > 0, |avatar| avatar.ml(px(-space::XS)))
2833 }))2837 }))
2838+ .when(more > 0, |this| {
2839+ this.child(super::parts::words(
2840+ format!("+{more}"),
2841+ super::parts::Text::Caption,
2842+ super::parts::Ink::Dim,
2843+ t,
2844+ ))
2845+ })
2834 })2846 })
2835 .child(super::parts::words(label, super::parts::Text::Ui, ink, t)),2847 .child(super::parts::words(label, super::parts::Text::Ui, ink, t)),
2836 )2848 )