diff --git a/crates/client/src/gui/builder/messages.rs b/crates/client/src/gui/builder/messages.rs index 75d0be1..598389d 100644 --- a/crates/client/src/gui/builder/messages.rs +++ b/crates/client/src/gui/builder/messages.rs @@ -4,7 +4,8 @@ use common::{ model::MessageHit, }; use gpui_kit::{ - AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement, Styled, Window, + AnyElement, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, + Styled, Window, assets::IconName, component::{WindowExt, notification::Notification}, div, @@ -13,13 +14,12 @@ use gpui_kit::{ }; use super::ui::{ - accent_button, card, confirmed, delete_icon_button, end_of_day_ms, icon_button, list_card, - list_row, start_of_day_ms, + accent_button, card, confirmed, delete_icon_button, end_of_day_ms, icon_button, start_of_day_ms, }; use crate::gui::YEAR_STAMP; -use crate::gui::style::{size, space, text}; +use crate::gui::style::{size, space, stroke, text}; use crate::gui::{ - Palette, Yumush, avatar, + Palette, Yumush, community_settings::user_name, entity_action, millis_time, notify_error, profile::user_link, @@ -31,12 +31,18 @@ fn message_hit_row( hit: &MessageHit, pending: bool, purge_pending: bool, - picture: Div, entity: &Entity, palette: Palette, ) -> Div { let message_id = hit.message.id; let community_id = hit.message.community_id; + let group = format!("hit_{}", hit.message.id); + let hue = hit + .author + .as_ref() + .map_or(palette.tokens.faint(), |author| { + palette.tokens.person(author.id) + }); let open = icon_button( format!("open_message_{}", hit.message.id), IconName::MessageSquare, @@ -76,13 +82,26 @@ fn message_hit_row( }) }); - list_row() - .child(user_link( - format!("hit_picture_{}", hit.message.id), - hit.author.as_ref(), - entity, - picture, - )) + let dot = div() + .absolute() + .left(px(space::XL - space::SM / 2.0)) + .top(px(space::SM)) + .size(px(space::SM)) + .rounded_full() + .bg(hue); + + div() + .group(group.clone()) + .relative() + .flex() + .items_start() + .gap(px(space::MD)) + .min_w_0() + .py(px(space::SM)) + .pl(px(space::XL + space::LG)) + .pr(px(space::LG)) + .hover(|style| style.bg(palette.hover)) + .child(dot) .child( div() .flex_1() @@ -103,24 +122,24 @@ fn message_hit_row( div() .truncate() .text_size(text(text::LABEL)) - .font_weight(FontWeight::MEDIUM) - .text_color(palette.text) + .font_weight(FontWeight::SEMIBOLD) + .text_color(hue) .child(user_name(&hit.author).to_string()), )) .child( div() - .min_w_0() - .truncate() + .flex_shrink_0() .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(hit.community.clone()), + .child(millis_time(hit.message.created_at, YEAR_STAMP)), ) .child( div() - .flex_shrink_0() + .min_w_0() + .truncate() .text_size(text(text::CAPTION)) - .text_color(palette.muted) - .child(millis_time(hit.message.created_at, YEAR_STAMP)), + .text_color(palette.tokens.faint()) + .child(hit.community.clone()), ), ) .child(match hit.message.call { @@ -128,7 +147,7 @@ fn message_hit_row( crate::gui::chat::call_line(call, user_name(&hit.author), false, palette) } None => div() - .text_size(text(text::LABEL)) + .text_size(text(text::BODY)) .text_color(palette.body) .line_clamp(2) .child(hit.message.body.clone()), @@ -136,10 +155,13 @@ fn message_hit_row( ) .child( div() + .id(format!("hit_actions_{}", hit.message.id)) .flex() .items_center() .gap(px(space::XS)) .flex_shrink_0() + .invisible() + .group_hover(group, |style| style.visible()) .child(open) .child(delete) .children(purge), @@ -201,27 +223,37 @@ impl Yumush { .author .as_ref() .is_some_and(|author| self.chat.pending_builder_purge == Some(author.id)); - let picture = match &hit.author { - Some(author) => avatar( - palette, - author, - px(size::AVATAR), - text(text::CAPTION), - &self.chat.avatars, - ), - None => div() - .size(px(size::AVATAR)) - .flex_shrink_0() - .rounded_full() - .bg(palette.hover), - }; - message_hit_row(hit, pending, purge_pending, picture, entity, palette) + message_hit_row(hit, pending, purge_pending, entity, palette) }) .collect(); + let list = if rows.is_empty() { + div() + .py(px(space::XL)) + .flex() + .justify_center() + .text_size(text(text::CAPTION)) + .text_color(palette.muted) + .child("No messages") + } else { + div() + .relative() + .flex() + .flex_col() + .child( + div() + .absolute() + .left(px(space::XL)) + .top_0() + .bottom_0() + .w(px(stroke::LINE)) + .bg(palette.tokens.thread()), + ) + .children(rows) + }; vec![ card(palette).child(filters).into_any_element(), - list_card(None, rows, "No messages", palette).into_any_element(), + card(palette).child(list).into_any_element(), ] } diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 47eafa2..cf957d7 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -6,7 +6,7 @@ use common::share::{Fps, Kind, Quality, Resolution}; use gpui_kit::{ AnyElement, AppContext as _, Context, Div, Entity, InteractiveElement, IntoElement, ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName, - component::Icon, div, px, + component::Icon, div, prelude::FluentBuilder as _, px, }; use super::{ @@ -30,7 +30,7 @@ const TILE_H: f32 = TILE_W * 9. / 16.; pub(super) const TILE_QUALITY: WatchQuality = WatchQuality::Fixed(Quality { resolution: Resolution::P360, - fps: Fps::F30, + fps: Fps::F15, }); #[derive(Clone, Copy, PartialEq, Eq)] @@ -254,7 +254,8 @@ impl Yumush { .voice_community() .map(|community_id| self.chat.voice_ids(community_id).to_vec()) .unwrap_or_default(); - self.voices_of(&ids, palette) + let others: Vec = ids.into_iter().filter(|id| !self.is_me(*id)).collect(); + self.voices_of(&others, palette) } fn slots(&self, ids: &[Id]) -> (Vec, usize) { @@ -293,6 +294,7 @@ impl Yumush { voice_line(self.chat.waves.voice(user.id), voice, t), t, ) + .h(px(size::CONTROL_SM)) }) .chain( (more > 0) @@ -359,7 +361,7 @@ impl Yumush { .chat .voice_ids(community_id) .iter() - .filter(|id| !sources.contains(&(**id, Kind::Camera))) + .filter(|id| !sources.contains(&(**id, Kind::Camera)) && !self.is_me(**id)) .copied() .collect(); let columns = ((sources.len() as f32).sqrt().ceil() as usize).max(1); @@ -489,19 +491,13 @@ fn stage_tile( .bg(t.raise()) .children(surface), ) - .child(caption( + .child(tile_name( name, - voice_line( - yumush.chat.waves.voice(user_id), - if speaking { - Voice::Live(t.person(user_id)) - } else if focused { - Voice::Live(t.paper()) - } else { - Voice::Quiet - }, - t, - ), + if speaking || focused { + Ink::Paper + } else { + Ink::Dim + }, t, )) } @@ -580,17 +576,9 @@ fn grid_cell( .bg(t.raise()) .children(surface), ) - .child(caption( + .child(tile_name( name, - voice_line( - yumush.chat.waves.voice(user_id), - if speaking { - Voice::Live(t.person(user_id)) - } else { - Voice::Quiet - }, - t, - ), + if speaking { Ink::Paper } else { Ink::Dim }, t, )) .into_any_element() @@ -607,20 +595,10 @@ pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, K || (yumush.is_me(user_id) && yumush.chat.voice_flags().is_some_and(|(muted, _)| muted)); scrim(t) - .child(words(name, Text::Label, Ink::Paper, t).flex_none()) .child( - div() - .w(px(size::CONTROL)) - .h(px(space::MD)) - .child(voice_line( - yumush.chat.waves.voice(user_id), - if speaking { - Voice::Live(t.person(user_id)) - } else { - Voice::Quiet - }, - t, - )), + words(name, Text::Label, Ink::Paper, t) + .flex_none() + .when(speaking, |name| name.text_color(t.person(user_id))), ) .children(muted.then(|| { Icon::new(IconName::MicOff) @@ -628,3 +606,11 @@ pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, K .text_color(t.bad()) })) } + +fn tile_name(name: impl Into, ink: Ink, t: super::style::Tokens) -> Div { + div() + .h(px(size::ICON)) + .flex() + .items_center() + .child(words(name, Text::Label, ink, t)) +} diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 0727443..f0fb857 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -1591,7 +1591,12 @@ impl Yumush { .map(|(index, message)| { let first = index == 0 || { let previous = &self.chat.messages[index - 1]; - previous.user_id != message.user_id || previous.call.is_some() + match message.call { + Some(_) => previous.call.is_none(), + None => { + previous.user_id != message.user_id || previous.call.is_some() + } + } }; let row = render_message( message, @@ -2869,6 +2874,7 @@ fn call_duration(seconds: u64) -> String { fn render_call( message: &Message, call: CallLog, + spaced: bool, chat: &Chat, me: Option<&User>, palette: Palette, @@ -2879,6 +2885,8 @@ fn render_call( .map_or("unknown", |user| user.username.as_str()); call_line(call, author, mine, palette) .id(format!("message_row_{}", message.id)) + .relative() + .when(spaced, |this| this.mt(px(space::LG))) .into_any_element() } @@ -2897,12 +2905,20 @@ pub(super) fn call_line(call: CallLog, author: &str, mine: bool, palette: Palett CallLog::Ended { seconds } => format!("Call ended ยท {}", call_duration(seconds)), }; div() + .relative() .flex() .items_center() - .gap(px(space::SM)) .text_size(text(text::CAPTION)) .text_color(palette.muted) - .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)) + .child( + div() + .absolute() + .left(px( + -(space::LG + space::XS) - (size::ICON_SM - space::SM) / 2. + )) + .bg(palette.window) + .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)), + ) .child(label) } @@ -2916,7 +2932,7 @@ fn render_message( palette: Palette, ) -> AnyElement { if let Some(call) = message.call { - return render_call(message, call, chat, me, palette); + return render_call(message, call, first && spaced, chat, me, palette); } let author = chat.author(message.user_id); let username = author.map_or("unknown", |user| user.username.as_str()); diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index c62a2d3..eb163de 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -363,6 +363,8 @@ pub enum Voice { Frayed, } +const STILL: f32 = 0.02; + pub fn voice_line(bands: Option<&VecDeque>, voice: Voice, t: Tokens) -> AnyElement { let levels: Vec = bands .map(|bands| bands.iter().copied().collect()) @@ -373,6 +375,15 @@ pub fn voice_line(bands: Option<&VecDeque>, voice: Voice, t: Tokens) -> Any Voice::Frayed => t.bad(), }; let frayed = voice == Voice::Frayed; + let peak = levels.iter().copied().fold(0., f32::max); + if peak < STILL && !frayed { + return div() + .size_full() + .flex() + .items_center() + .child(div().w_full().h(px(stroke::LINE)).bg(color)) + .into_any_element(); + } canvas( |_, _, _| {}, move |bounds, _, window, _| { @@ -386,11 +397,11 @@ pub fn voice_line(bands: Option<&VecDeque>, voice: Voice, t: Tokens) -> Any } for step in 0..=steps { let along = step as f32 / steps as f32; - let level = sample(&levels, along); - let envelope = (std::f32::consts::PI * along).sin(); + let level = ((sample(&levels, along) + peak) / 2.).sqrt(); + let envelope = (std::f32::consts::PI * along).sin().sqrt(); let swing = (step as f32 * 0.9).sin(); let x = bounds.origin.x + bounds.size.width * along; - let y = middle + px(swing * level * envelope * half * 0.9); + let y = middle + px(swing * level * envelope * half); if step == 0 { path.move_to(point(x, y)); } else { diff --git a/crates/client/src/gui/settings_page.rs b/crates/client/src/gui/settings_page.rs index 532cb25..f1af327 100644 --- a/crates/client/src/gui/settings_page.rs +++ b/crates/client/src/gui/settings_page.rs @@ -3,7 +3,8 @@ use std::future::Future; use crate::net::Fail; use common::{ call::{DeleteUser, RemoveAvatar, UpdateAvatar, UpdateHue, UpdateStatus, UpdateUser}, - model::{Hue, User}, + model::{Hue, Presence, User}, + share::{self, Kind}, }; use gpui_kit::{ AnyElement, App, AsyncWindowContext, Context, Div, Entity, FontWeight, Hsla, @@ -17,12 +18,18 @@ use gpui_kit::{ }; use super::{ - Palette, Tooltip as _, Yumush, avatar, chat::DeleteStep, chat::View, clickable, notify_error, - primary_button, text, widget::field, + Palette, Tooltip as _, Yumush, avatar, + chat::DeleteStep, + chat::View, + clickable, notify_error, parts, primary_button, + share_view::{AudioMode, CODECS, FPS, RESOLUTIONS, share_modes}, + text, + widget::field, }; use crate::{ gui::style::{self, Theme, radius, size, space, stroke, text}, - settings::{self, FontSize}, + settings::{self, FontSize, ShareAudio, ShareCodec}, + share::encode::capabilities, }; impl Yumush { @@ -34,6 +41,8 @@ impl Yumush { ) -> impl IntoElement { let mut sections = Vec::new(); if let Some(user) = self.user.as_ref() { + let presence_entity = entity.clone(); + let logout_entity = entity.clone(); sections.push(Section( "Profile", div() @@ -59,41 +68,74 @@ impl Yumush { entity, palette, )) - .child(row( - "Hue", - hue_picker(Some(style::hue_of(user.id)), entity, palette), - )) - .into_any_element(), - )); - sections.push(section( - "Account", - palette, - vec![ - text_row( - Editable { - id: "save_username_button", - label: "Username", - input: &self.chat.username_input, - current: &user.username, - save: Yumush::save_username, - }, - entity, + .child(titled( + "Identity", palette, - cx, - ), - text_row( - Editable { - id: "save_status_button", - label: "Status", - input: &self.chat.status_input, - current: &user.status, - save: Yumush::save_status, - }, - entity, + rows_column( + palette, + vec![ + text_row( + Editable { + id: "save_username_button", + label: "Name", + input: &self.chat.username_input, + current: &user.username, + save: Yumush::save_username, + }, + entity, + palette, + cx, + ), + text_row( + Editable { + id: "save_status_button", + label: "Status", + input: &self.chat.status_input, + current: &user.status, + save: Yumush::save_status, + }, + entity, + palette, + cx, + ), + row( + "Presence", + parts::options( + "presence", + Presence::ALL.map(|presence| (presence, presence.label())), + self.presence_of(user.id), + palette.tokens, + move |presence, window, cx| { + presence_entity.update(cx, |yumush, cx| { + yumush.set_presence(presence, window, cx) + }) + }, + ), + ), + ], + ), + )) + .child(titled( + "Account", palette, - cx, - ), - ], + rows_column( + palette, + vec![row( + "Log out", + small_button( + "logout_button", + palette, + palette.danger, + move |window, cx| { + logout_entity + .update(cx, |yumush, cx| yumush.logout(window, cx)) + }, + ) + .child("Log out"), + )], + ), + )) + .into_any_element(), )); } sections.push(section( @@ -101,49 +143,56 @@ impl Yumush { palette, self.voice_rows(entity, palette, cx), )); - sections.push(section( - "Appearance", - palette, - vec![ - row( - "Theme", - segmented( - Theme::ALL.map(|choice| (choice, choice.label())), - self.settings.theme, - entity, - palette, - Yumush::set_theme, - ), + sections.push(Section( + "Camera & share", + camera_share(self, entity, palette), + )); + let mut appearance = vec![ + row( + "Theme", + segmented( + Theme::ALL.map(|choice| (choice, choice.label())), + self.settings.theme, + entity, + palette, + Yumush::set_theme, ), - row( - "Font size", - segmented( - FontSize::ALL.map(|size| (size, size.label())), - self.settings.font_size, - entity, - palette, - Yumush::set_font_size, - ), + ), + row( + "Font size", + segmented( + FontSize::ALL.map(|size| (size, size.label())), + self.settings.font_size, + entity, + palette, + Yumush::set_font_size, ), - row( - "Close to tray", - super::parts::toggle( - "close_to_tray_switch", - self.settings.close_to_tray, - palette.tokens, - { - let entity = entity.clone(); - move |_, cx| { - entity.update(cx, |yumush, cx| { - yumush.settings.close_to_tray = !yumush.settings.close_to_tray; - yumush.commit_settings(cx); - }) - } - }, - ), + ), + row( + "Close to tray", + super::parts::toggle( + "close_to_tray_switch", + self.settings.close_to_tray, + palette.tokens, + { + let entity = entity.clone(); + move |_, cx| { + entity.update(cx, |yumush, cx| { + yumush.settings.close_to_tray = !yumush.settings.close_to_tray; + yumush.commit_settings(cx); + }) + } + }, ), - ], - )); + ), + ]; + if let Some(user) = self.user.as_ref() { + appearance.push(row( + "Your hue", + hue_picker(Some(style::hue_of(user.id)), entity, palette), + )); + } + sections.push(section("Appearance", palette, appearance)); if self.user.is_some() { sections.push(danger_section( palette, @@ -332,6 +381,135 @@ fn hue_picker(current: Option, entity: &Entity, palette: Palette) - })) } +fn camera_share(yumush: &Yumush, entity: &Entity, palette: Palette) -> AnyElement { + div() + .flex() + .flex_col() + .gap(px(space::XL)) + .child(titled( + "Camera", + palette, + rows_column(palette, camera_rows(yumush, entity, palette)), + )) + .child(titled( + "Screen share", + palette, + rows_column(palette, screen_rows(yumush, entity, palette)), + )) + .into_any_element() +} + +fn camera_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Vec
{ + let modes = share_modes(yumush, Kind::Camera); + let max_height = capabilities().max_height; + let top = share::clamp(yumush.settings.share.top(Kind::Camera), &modes, max_height); + let (resolutions, fps) = share::options(&modes, top.resolution, max_height); + vec![ + row( + "Quality", + parts::options( + "camera_quality", + RESOLUTIONS + .into_iter() + .filter(|(resolution, _)| resolutions.contains(resolution)), + top.resolution, + palette.tokens, + share_pick(entity, Kind::Camera, Yumush::set_share_resolution), + ), + ), + row( + "Frame rate", + parts::options( + "camera_fps", + FPS.into_iter().filter(|(value, _)| fps.contains(value)), + top.fps, + palette.tokens, + share_pick(entity, Kind::Camera, Yumush::set_share_fps), + ), + ), + ] +} + +fn screen_rows(yumush: &Yumush, entity: &Entity, palette: Palette) -> Vec
{ + let settings = &yumush.settings.share; + let modes = share_modes(yumush, Kind::Screen); + let max_height = capabilities().max_height; + let top = share::clamp(settings.top(Kind::Screen), &modes, max_height); + let (resolutions, fps) = share::options(&modes, top.resolution, max_height); + let audio_on = settings.audio != ShareAudio::Off; + let audio_entity = entity.clone(); + vec![ + row( + "Quality", + parts::options( + "screen_quality", + RESOLUTIONS + .into_iter() + .filter(|(resolution, _)| resolutions.contains(resolution)), + top.resolution, + palette.tokens, + share_pick(entity, Kind::Screen, Yumush::set_share_resolution), + ), + ), + row( + "Frame rate", + parts::options( + "screen_fps", + FPS.into_iter().filter(|(value, _)| fps.contains(value)), + top.fps, + palette.tokens, + share_pick(entity, Kind::Screen, Yumush::set_share_fps), + ), + ), + row( + "Codec", + parts::options( + "share_codec", + CODECS.into_iter().filter(|(codec, _)| match codec { + ShareCodec::Auto => true, + ShareCodec::Only(codec) => capabilities().encode.contains(codec), + }), + settings.codec, + palette.tokens, + share_pick(entity, Kind::Screen, Yumush::set_share_codec), + ), + ), + row( + "Share audio", + parts::toggle( + "share_audio_switch", + audio_on, + palette.tokens, + move |_, cx| { + audio_entity.update(cx, |yumush, cx| { + let mode = if audio_on { + AudioMode::Off + } else { + AudioMode::Everything + }; + yumush.set_share_audio_mode(mode, cx) + }) + }, + ), + ), + ] +} + +fn share_pick( + entity: &Entity, + kind: Kind, + set: fn(&mut Yumush, T, &mut Context), +) -> impl Fn(T, &mut Window, &mut App) + Clone + 'static { + let entity = entity.clone(); + move |value, _, cx| { + entity.update(cx, |yumush, cx| { + let tab = std::mem::replace(&mut yumush.share_tab, kind); + set(yumush, value, cx); + yumush.share_tab = tab; + }) + } +} + pub(super) fn picked_avatar( cx: &App, maximum: u64, @@ -469,6 +647,14 @@ pub(super) fn danger_section(palette: Palette, rows: Vec
) -> Section { Section("Danger zone", rows_column(palette, rows)) } +fn titled(title: &'static str, palette: Palette, rows: impl IntoElement) -> Div { + div() + .flex() + .flex_col() + .child(parts::section(title, palette.tokens)) + .child(rows) +} + fn rows_column(palette: Palette, rows: Vec
) -> AnyElement { div() .flex() diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index ba76480..c95656e 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -56,7 +56,7 @@ const BAR_TTL: Duration = Duration::from_millis(2500); const APPS_REFRESH: Duration = Duration::from_secs(2); const APPS_IDLE: Duration = Duration::from_secs(5); -const RESOLUTIONS: [(Resolution, &str); 6] = [ +pub(super) const RESOLUTIONS: [(Resolution, &str); 6] = [ (Resolution::P360, "360"), (Resolution::P480, "480"), (Resolution::P720, "720"), @@ -64,9 +64,9 @@ const RESOLUTIONS: [(Resolution, &str); 6] = [ (Resolution::P1440, "1440"), (Resolution::P2160, "2160"), ]; -const FPS: [(Fps, &str); 3] = [(Fps::F15, "15"), (Fps::F30, "30"), (Fps::F60, "60")]; +pub(super) const FPS: [(Fps, &str); 3] = [(Fps::F15, "15"), (Fps::F30, "30"), (Fps::F60, "60")]; -const CODECS: [(ShareCodec, &str); 4] = [ +pub(super) const CODECS: [(ShareCodec, &str); 4] = [ (ShareCodec::Auto, "Auto"), (ShareCodec::Only(Codec::Av1), "AV1"), (ShareCodec::Only(Codec::H265), "H265"), @@ -795,7 +795,7 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> }) } -fn share_modes(yumush: &Yumush, kind: Kind) -> Vec { +pub(super) fn share_modes(yumush: &Yumush, kind: Kind) -> Vec { yumush .network .share_modes(kind) diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index 9826613..1e1041f 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -187,12 +187,14 @@ impl Yumush { .flex() .items_center() .gap(px(space::XS)) - .child( - div() - .w(px(size::CONTROL)) - .h(px(space::MD)) - .child(super::parts::voice_line(wave, voice, palette.tokens)), - ) + .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() .text_size(text(text::CAPTION)) @@ -242,11 +244,6 @@ impl Yumush { let speaking = self.chat.waves.speaking.contains(&user_id); let shown = speaking || (me && !muted); let wave = shown.then(|| self.chat.waves.voice(user_id)).flatten(); - let voice = if wave.is_some() { - super::parts::Voice::Live(palette.tinted(user_id)) - } else { - super::parts::Voice::Quiet - }; let camera = self .chat .share_of(community_id, user_id, Kind::Camera) @@ -277,13 +274,6 @@ impl Yumush { .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD)) .child(user.username.clone()), ) - .child( - div() - .w(px(size::CONTROL)) - .h(px(space::MD)) - .flex_none() - .child(super::parts::voice_line(wave, voice, palette.tokens)), - ) .children((muted && wave.is_none()).then(|| { Icon::new(IconName::MicOff) .size(px(size::ICON_SM)) @@ -942,13 +932,6 @@ impl Yumush { named: bool, palette: Palette, ) -> impl IntoElement { - let speaking = self.chat.waves.speaking.contains(&user.id); - let own_wave = self.chat.waves.voice(user.id); - let own_voice = if speaking { - super::parts::Voice::Live(palette.tokens.person(user.id)) - } else { - super::parts::Voice::Quiet - }; profile_popover( "account_profile", Anchor::BottomLeft, @@ -978,24 +961,13 @@ impl Yumush { )) }) .when(named, |trigger| { - trigger - .child( - div() - .min_w_0() - .truncate() - .text_color(palette.muted) - .child(user.username.clone()), - ) - .child( - div() - .w(px(size::CONTROL + space::LG)) - .h(px(space::MD)) - .child(super::parts::voice_line( - own_wave, - own_voice, - palette.tokens, - )), - ) + trigger.child( + div() + .min_w_0() + .truncate() + .text_color(palette.muted) + .child(user.username.clone()), + ) }), palette, ),