use common::share::Kind; use gpui_kit::{App, Entity, IntoElement}; use super::{ Yumush, call_bar::{self, CallActions, CallBar}, entity_action, parts::Voice, style::Tokens, voice_stats::{self, Quality}, }; impl Yumush { pub(super) fn dock( &self, entity: &Entity, t: Tokens, cx: &App, ) -> Option { let community = self.chat.voice_room()?; let (muted, deafened) = self.chat.voice_flags()?; let user = self.user.as_ref()?; let me = user.id; let quality = voice_stats::quality(&self.chat.session.stats.voice); let frayed = quality == Some(Quality::Poor); let screen = self.network.share_source(Kind::Screen).is_some(); let voice = if frayed { Voice::Frayed } else if !muted && self.chat.session.waves.speaking.contains(&me) { Voice::Live(t.person(me)) } else { Voice::Quiet }; let bar = CallBar { place: super::community_name(community).to_string().into(), bands: self.chat.session.waves.voice(me).map(super::chat::to_bands), voice, quality, pings: self .chat .session .stats .voice .iter() .map(|sample| sample.ping_ms) .collect(), muted, deafened, camera: self.network.share_source(Kind::Camera).is_some(), ghost: self.chat.session.ghost, share: screen.then(|| { ( self.chat.session.waves.share(me).map(super::chat::to_bands), t.person(me), ) }), stats: self.chat.stats_at == Some(super::chat::StatsAt::Dock), }; let go_id = community.id; let actions = CallActions { go: Box::new(entity_action(entity, move |yumush, window, cx| { yumush.select_community(go_id, window, cx); })), mute: Box::new(entity_action(entity, |yumush, window, cx| { yumush.toggle_mute(window, cx) })), deafen: Box::new(entity_action(entity, |yumush, _, cx| { yumush.toggle_deafen(cx) })), camera: Box::new(entity_action(entity, |yumush, window, cx| { yumush.toggle_camera(window, cx) })), screen: Box::new(entity_action(entity, |yumush, window, cx| { yumush.toggle_share(window, cx) })), leave: Box::new(entity_action(entity, |yumush, _, cx| { yumush.end_voice(cx); cx.notify(); })), stats: Box::new(entity_action(entity, move |yumush, window, cx| { yumush.select_community(go_id, window, cx); yumush.toggle_stats(super::chat::StatsAt::Dock); cx.notify(); })), mic_more: self .audio_button(entity, t, super::voice_settings::Side::Input, cx) .into_any_element(), speaker_more: self .audio_button(entity, t, super::voice_settings::Side::Output, cx) .into_any_element(), camera_more: self .share_settings_button(entity, t, Kind::Camera, cx) .into_any_element(), screen_more: self .share_settings_button(entity, t, Kind::Screen, cx) .into_any_element(), }; Some(call_bar::view(bar, actions, t)) } }