Profile card has Call beside Message and a Mute toggle under volume
Browse files at this commitc9913293d444588f77daf03f789a6487248bc8afParent: 51c4d98- feat
- profile card has Call beside Message and a Mute toggle under volume
3 changed files +74 -3
- crates/client/src/gui/chat.rs +24 -0
- crates/client/src/gui/profile.rs +31 -3
- crates/client/src/gui/social.rs +19 -0
crates/client/src/gui/chat.rsmodified+24 -0
| @@ -2392,6 +2392,30 @@ impl Yumush { | |||
| 2392 | }); | 2392 | }); |
| 2393 | } | 2393 | } |
| 2394 | 2394 | ||
| 2395 | + pub(super) fn toggle_user_mute( | ||
| 2396 | + &mut self, | ||
| 2397 | + user_id: Id, | ||
| 2398 | + window: &mut Window, | ||
| 2399 | + cx: &mut Context<Self>, | ||
| 2400 | + ) { | ||
| 2401 | + let volume = if self.user_volume(user_id) == 0. { | ||
| 2402 | + DEFAULT_USER_VOLUME | ||
| 2403 | + } else { | ||
| 2404 | + 0. | ||
| 2405 | + }; | ||
| 2406 | + let volumes = &mut self.settings.voice.user_volumes; | ||
| 2407 | + match volume { | ||
| 2408 | + DEFAULT_USER_VOLUME => volumes.remove(&user_id), | ||
| 2409 | + volume => volumes.insert(user_id, volume), | ||
| 2410 | + }; | ||
| 2411 | + if let Some(user_volume) = self.chat.user_volume.as_ref() { | ||
| 2412 | + user_volume | ||
| 2413 | + .slider | ||
| 2414 | + .update(cx, |slider, cx| slider.set_value(volume, window, cx)); | ||
| 2415 | + } | ||
| 2416 | + self.commit_settings(cx); | ||
| 2417 | + } | ||
| 2418 | + | ||
| 2395 | pub(super) fn user_volume(&self, user_id: Id) -> f32 { | 2419 | pub(super) fn user_volume(&self, user_id: Id) -> f32 { |
| 2396 | self.settings | 2420 | self.settings |
| 2397 | .voice | 2421 | .voice |
crates/client/src/gui/profile.rsmodified+31 -3
| @@ -171,6 +171,17 @@ impl Card { | |||
| 171 | }), | 171 | }), |
| 172 | ) | 172 | ) |
| 173 | .into_any_element(), | 173 | .into_any_element(), |
| 174 | + menu_row( | ||
| 175 | + "profile_call", | ||
| 176 | + "Call", | ||
| 177 | + menu_icon(IconName::Phone), | ||
| 178 | + palette.text, | ||
| 179 | + palette, | ||
| 180 | + yumush_action(entity, popover, move |yumush, window, cx| { | ||
| 181 | + yumush.call_direct(message_id, window, cx) | ||
| 182 | + }), | ||
| 183 | + ) | ||
| 184 | + .into_any_element(), | ||
| 174 | ]; | 185 | ]; |
| 175 | 186 | ||
| 176 | let report_user_id = self.user.id; | 187 | let report_user_id = self.user.id; |
| @@ -232,13 +243,16 @@ impl Card { | |||
| 232 | } else { | 243 | } else { |
| 233 | let mut rows = self.social_rows(entity, &popover, palette); | 244 | let mut rows = self.social_rows(entity, &popover, palette); |
| 234 | rows.extend(self.moderation_rows(entity, &popover, palette)); | 245 | rows.extend(self.moderation_rows(entity, &popover, palette)); |
| 235 | - if self.card_menu == CardMenu::More || rows.len() < 2 { | 246 | + if self.card_menu == CardMenu::More || rows.len() < 3 { |
| 236 | rows | 247 | rows |
| 237 | } else { | 248 | } else { |
| 238 | let first = rows.remove(0); | 249 | let first = rows.remove(0); |
| 250 | + let second = rows.remove(0); | ||
| 239 | vec![ | 251 | vec![ |
| 240 | band(space::XS) | 252 | band(space::XS) |
| 241 | - .child(div().flex_1().child(first)) | 253 | + .child(first) |
| 254 | + .child(second) | ||
| 255 | + .child(div().flex_1()) | ||
| 242 | .child(icon_button( | 256 | .child(icon_button( |
| 243 | "profile_more", | 257 | "profile_more", |
| 244 | IconName::Ellipsis, | 258 | IconName::Ellipsis, |
| @@ -308,7 +322,7 @@ impl Card { | |||
| 308 | )) | 322 | )) |
| 309 | })) | 323 | })) |
| 310 | .child(words(about, Text::Caption, Ink::Faint, t)) | 324 | .child(words(about, Text::Caption, Ink::Faint, t)) |
| 311 | - .children(self.volume.map(|(slider, volume)| { | 325 | + .children(self.volume.clone().map(|(slider, volume)| { |
| 312 | band(space::MD) | 326 | band(space::MD) |
| 313 | .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) | 327 | .child(words("Volume", Text::Label, Ink::Paper, t).flex_none()) |
| 314 | .child(super::parts::slider(&slider, t)) | 328 | .child(super::parts::slider(&slider, t)) |
| @@ -318,6 +332,20 @@ impl Card { | |||
| 318 | .text_right(), | 332 | .text_right(), |
| 319 | ) | 333 | ) |
| 320 | })) | 334 | })) |
| 335 | + .children(self.volume.as_ref().map(|(_, volume)| { | ||
| 336 | + let user_id = self.user.id; | ||
| 337 | + band(space::MD) | ||
| 338 | + .child(words("Mute", Text::Label, Ink::Paper, t)) | ||
| 339 | + .child(div().flex_1()) | ||
| 340 | + .child(super::parts::toggle( | ||
| 341 | + "profile_mute", | ||
| 342 | + *volume == 0., | ||
| 343 | + t, | ||
| 344 | + entity_action(entity, move |yumush, window, cx| { | ||
| 345 | + yumush.toggle_user_mute(user_id, window, cx) | ||
| 346 | + }), | ||
| 347 | + )) | ||
| 348 | + })) | ||
| 321 | .children( | 349 | .children( |
| 322 | self.reporting | 350 | self.reporting |
| 323 | .then(|| report_bar(&self.reason, entity, palette)), | 351 | .then(|| report_bar(&self.reason, entity, palette)), |
crates/client/src/gui/social.rsmodified+19 -0
| @@ -215,6 +215,25 @@ impl Yumush { | |||
| 215 | }); | 215 | }); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | + pub(super) fn call_direct(&self, user_id: Id, window: &mut Window, cx: &mut Context<Self>) { | ||
| 219 | + let network = self.network.clone(); | ||
| 220 | + cx.spawn_in(window, async move |this, cx| { | ||
| 221 | + match network.call(OpenDirect { user_id }).await { | ||
| 222 | + Ok(community) => { | ||
| 223 | + let _ = this.update_in(cx, |yumush, window, cx| { | ||
| 224 | + let community_id = community.id; | ||
| 225 | + yumush.enter_community(community, window, cx); | ||
| 226 | + if !yumush.chat.in_voice(community_id) { | ||
| 227 | + yumush.toggle_voice(community_id, window, cx); | ||
| 228 | + } | ||
| 229 | + }); | ||
| 230 | + } | ||
| 231 | + Err(error) => notify_error(&this, cx, error), | ||
| 232 | + } | ||
| 233 | + }) | ||
| 234 | + .detach(); | ||
| 235 | + } | ||
| 236 | + | ||
| 218 | pub(super) fn friend_action( | 237 | pub(super) fn friend_action( |
| 219 | &self, | 238 | &self, |
| 220 | relation: Relation, | 239 | relation: Relation, |