diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index fe9442e..f0d78c8 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -2392,6 +2392,30 @@ impl Yumush { }); } + pub(super) fn toggle_user_mute( + &mut self, + user_id: Id, + window: &mut Window, + cx: &mut Context, + ) { + let volume = if self.user_volume(user_id) == 0. { + DEFAULT_USER_VOLUME + } else { + 0. + }; + let volumes = &mut self.settings.voice.user_volumes; + match volume { + DEFAULT_USER_VOLUME => volumes.remove(&user_id), + volume => volumes.insert(user_id, volume), + }; + if let Some(user_volume) = self.chat.user_volume.as_ref() { + user_volume + .slider + .update(cx, |slider, cx| slider.set_value(volume, window, cx)); + } + self.commit_settings(cx); + } + pub(super) fn user_volume(&self, user_id: Id) -> f32 { self.settings .voice diff --git a/crates/client/src/gui/profile.rs b/crates/client/src/gui/profile.rs index 304fae7..42ba09b 100644 --- a/crates/client/src/gui/profile.rs +++ b/crates/client/src/gui/profile.rs @@ -171,6 +171,17 @@ impl Card { }), ) .into_any_element(), + menu_row( + "profile_call", + "Call", + menu_icon(IconName::Phone), + palette.text, + palette, + yumush_action(entity, popover, move |yumush, window, cx| { + yumush.call_direct(message_id, window, cx) + }), + ) + .into_any_element(), ]; let report_user_id = self.user.id; @@ -232,13 +243,16 @@ impl Card { } else { let mut rows = self.social_rows(entity, &popover, palette); rows.extend(self.moderation_rows(entity, &popover, palette)); - if self.card_menu == CardMenu::More || rows.len() < 2 { + if self.card_menu == CardMenu::More || rows.len() < 3 { rows } else { let first = rows.remove(0); + let second = rows.remove(0); vec![ band(space::XS) - .child(div().flex_1().child(first)) + .child(first) + .child(second) + .child(div().flex_1()) .child(icon_button( "profile_more", IconName::Ellipsis, @@ -308,7 +322,7 @@ impl Card { )) })) .child(words(about, Text::Caption, Ink::Faint, t)) - .children(self.volume.map(|(slider, volume)| { + .children(self.volume.clone().map(|(slider, volume)| { band(space::MD) .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) .child(super::parts::slider(&slider, t)) @@ -318,6 +332,20 @@ impl Card { .text_right(), ) })) + .children(self.volume.as_ref().map(|(_, volume)| { + let user_id = self.user.id; + band(space::MD) + .child(words("Mute", Text::Label, Ink::Paper, t)) + .child(div().flex_1()) + .child(super::parts::toggle( + "profile_mute", + *volume == 0., + t, + entity_action(entity, move |yumush, window, cx| { + yumush.toggle_user_mute(user_id, window, cx) + }), + )) + })) .children( self.reporting .then(|| report_bar(&self.reason, entity, palette)), diff --git a/crates/client/src/gui/social.rs b/crates/client/src/gui/social.rs index 7b56db7..a066f48 100644 --- a/crates/client/src/gui/social.rs +++ b/crates/client/src/gui/social.rs @@ -215,6 +215,25 @@ impl Yumush { }); } + pub(super) fn call_direct(&self, user_id: Id, window: &mut Window, cx: &mut Context) { + let network = self.network.clone(); + cx.spawn_in(window, async move |this, cx| { + match network.call(OpenDirect { user_id }).await { + Ok(community) => { + let _ = this.update_in(cx, |yumush, window, cx| { + let community_id = community.id; + yumush.enter_community(community, window, cx); + if !yumush.chat.in_voice(community_id) { + yumush.toggle_voice(community_id, window, cx); + } + }); + } + Err(error) => notify_error(&this, cx, error), + } + }) + .detach(); + } + pub(super) fn friend_action( &self, relation: Relation,