From 3f99fc41586b3136c0b4af73d71f0e99939a592f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 27 Nov 2026 23:53:22 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20sidebar=20call=20meter=20sh?= =?UTF-8?q?ows=20the=20room's=20total=20spectrum=20(all=20speakers=20summe?= =?UTF-8?q?d;=20one=20speaker's=20hue,=20several=20=3D=20paper),=20also=20?= =?UTF-8?q?for=20your=20own=20call;=20chevron=20folds=20your=20call's=20me?= =?UTF-8?q?mber=20list,=20meter=20stays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/chat.rs | 2 + crates/client/src/gui/sidebar.rs | 63 +++++++++++++++++++++++--------- crates/client/src/gui/wave.rs | 11 ++++++ 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index dd64de1..252630c 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -134,6 +134,7 @@ pub struct Chat { pub(super) selected_community_id: Option, pub(super) opened: Option, pub(super) ghost: bool, + pub(super) call_folded: bool, pub(super) members: Vec, pub(super) messages: Vec, pub(super) pins: Vec, @@ -377,6 +378,7 @@ impl Chat { selected_community_id: None, opened: None, ghost: false, + call_folded: false, members: vec![], bans: vec![], ban_search, diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 9996858..94c3a82 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -167,31 +167,33 @@ impl Yumush { .into_any_element() } - fn voice_chip(&self, community_id: Id, palette: Palette) -> AnyElement { + fn voice_chip(&self, entity: &Entity, community_id: Id, palette: Palette) -> AnyElement { let ids = self.chat.voice_ids(community_id); - let speaker = ids + let t = palette.tokens; + let mut speakers = ids .iter() - .find(|id| self.chat.waves.speaking.contains(id)) - .copied(); - let wave = speaker.and_then(|id| self.chat.waves.voice(id)); - let voice = match speaker { - Some(id) => super::parts::Voice::Live(palette.tokens.person(id)), - None => super::parts::Voice::Quiet, + .filter(|id| self.chat.waves.speaking.contains(id)); + let voice = match (speakers.next(), speakers.next()) { + (Some(id), None) => super::parts::Voice::Live(t.person(*id)), + (Some(_), Some(_)) => super::parts::Voice::Live(t.paper()), + _ => super::parts::Voice::Quiet, }; + let total = self.chat.waves.total(ids); + let own = self.chat.voice_community() == Some(community_id); + let folded = self.chat.call_folded; + let fold = entity.clone(); div() .id(format!("voice_chip_{community_id}")) .tip("In call") .flex() .items_center() .gap(px(space::XS)) - .when(self.chat.voice_community() != Some(community_id), |this| { - this.child( - div() - .w(px(size::CONTROL)) - .h(px(space::MD)) - .child(super::parts::voice_line(wave, voice, palette.tokens)), - ) - }) + .child( + div() + .w(px(size::CONTROL)) + .h(px(space::MD)) + .child(super::parts::voice_line(total.as_ref(), voice, t)), + ) .when(!self.is_direct(community_id), |this| { this.child( div() @@ -200,11 +202,36 @@ impl Yumush { .child(ids.len().to_string()), ) }) + .when(own, |this| { + this.child( + div() + .id(format!("call_fold_{community_id}")) + .flex_none() + .cursor_pointer() + .text_color(t.faint()) + .hover(|style| style.text_color(t.paper())) + .on_click(move |_, _, cx| { + cx.stop_propagation(); + fold.update(cx, |yumush, cx| { + yumush.chat.call_folded = !yumush.chat.call_folded; + cx.notify(); + }); + }) + .child( + Icon::new(if folded { + IconName::ChevronRight + } else { + IconName::ChevronDown + }) + .size(px(size::ICON_SM)), + ), + ) + }) .into_any_element() } fn call_tree(&self, entity: &Entity, community_id: Id, palette: Palette) -> Option
{ - if self.chat.voice_community() != Some(community_id) { + if self.chat.voice_community() != Some(community_id) || self.chat.call_folded { return None; } let members = self @@ -530,7 +557,7 @@ impl Yumush { let trailing = if self.chat.voice_ids(community_id).is_empty() { unread_badge(palette, muted, unread) } else { - Some(self.voice_chip(community_id, palette)) + Some(self.voice_chip(entity, community_id, palette)) }; let face = match &community.kind { CommunityKind::Direct { peer } => Some(presence_avatar( diff --git a/crates/client/src/gui/wave.rs b/crates/client/src/gui/wave.rs index 8c12116..26f7855 100644 --- a/crates/client/src/gui/wave.rs +++ b/crates/client/src/gui/wave.rs @@ -127,6 +127,17 @@ impl Waves { self.voice.get(&id).map(|wave| &wave.bars) } + pub fn total(&self, ids: &[Id]) -> Option> { + let mut waves = ids.iter().filter_map(|id| self.voice(*id)); + let first = waves.next()?.clone(); + Some(waves.fold(first, |mut sum, bars| { + sum.iter_mut() + .zip(bars) + .for_each(|(sum, bar)| *sum = (*sum + bar).min(1.)); + sum + })) + } + pub fn share(&self, id: Id) -> Option<&VecDeque> { self.share.get(&id).map(|wave| &wave.bars) }