Call people live in the room margin (In call with voice lines and watch buttons)
Browse files at this commit153c8a91cf5febcd3953e4d8ed3954bc94e4f2baParent: 7a25d82- style
- call people live in the room margin (In call with voice lines and watch buttons)
- sidebar room row keeps only the line and count
4 changed files +52 -159
- crates/client/lang/en/chat.txt +1 -0
- crates/client/lang/tr/chat.txt +1 -0
- crates/client/src/gui/chat.rs +46 -8
- crates/client/src/gui/sidebar.rs +4 -151
crates/client/lang/en/chat.txtmodified+1 -0
| @@ -60,3 +60,4 @@ call_declined = {name} declined the call | ||
| 60 | 60 | call_missed_mine = You called, no answer |
| 61 | 61 | call_missed = Missed call from {name} |
| 62 | 62 | call_ended = Call ended · {duration} |
| 63 | +in_call = In call |
crates/client/lang/tr/chat.txtmodified+1 -0
| @@ -60,3 +60,4 @@ call_declined = {name} aramayı reddetti | ||
| 60 | 60 | call_missed_mine = Aradın, cevap yok |
| 61 | 61 | call_missed = Cevapsız arama: {name} |
| 62 | 62 | call_ended = Arama bitti · {duration} |
| 63 | +in_call = Aramada |
crates/client/src/gui/chat.rsmodified+46 -8
| @@ -134,7 +134,6 @@ pub struct Chat { | ||
| 134 | 134 | pub(super) selected_community_id: Option<Id>, |
| 135 | 135 | pub(super) opened: Option<Community>, |
| 136 | 136 | pub(super) ghost: bool, |
| 137 | - pub(super) call_folded: bool, | |
| 138 | 137 | pub(super) members: Vec<Member>, |
| 139 | 138 | pub(super) messages: Vec<Message>, |
| 140 | 139 | pub(super) pins: Vec<Message>, |
| @@ -395,7 +394,6 @@ impl Chat { | ||
| 395 | 394 | selected_community_id: None, |
| 396 | 395 | opened: None, |
| 397 | 396 | ghost: false, |
| 398 | - call_folded: false, | |
| 399 | 397 | members: vec![], |
| 400 | 398 | bans: vec![], |
| 401 | 399 | ban_search, |
| @@ -3012,6 +3010,7 @@ impl Yumush { | ||
| 3012 | 3010 | |
| 3013 | 3011 | struct MemberRow { |
| 3014 | 3012 | user: User, |
| 3013 | + in_voice: bool, | |
| 3015 | 3014 | muted: bool, |
| 3016 | 3015 | presence: Presence, |
| 3017 | 3016 | } |
| @@ -3022,18 +3021,20 @@ fn members_column( | ||
| 3022 | 3021 | palette: Palette, |
| 3023 | 3022 | ) -> Option<gpui_kit::Stateful<Div>> { |
| 3024 | 3023 | let chat = &yumush.chat; |
| 3025 | - chat.selected_community_id?; | |
| 3024 | + let community_id = chat.selected_community_id?; | |
| 3026 | 3025 | let group = chat |
| 3027 | 3026 | .selected_community() |
| 3028 | 3027 | .is_some_and(|community| matches!(community.kind, CommunityKind::Group)); |
| 3029 | 3028 | if !chat.members_open || !group { |
| 3030 | 3029 | return None; |
| 3031 | 3030 | } |
| 3031 | + let voice = chat.voice_ids(community_id); | |
| 3032 | 3032 | let members: Vec<MemberRow> = chat |
| 3033 | 3033 | .members |
| 3034 | 3034 | .iter() |
| 3035 | 3035 | .map(|member| MemberRow { |
| 3036 | 3036 | user: member.user.clone(), |
| 3037 | + in_voice: voice.contains(&member.user.id), | |
| 3037 | 3038 | muted: chat.server_muted.contains(&member.user.id), |
| 3038 | 3039 | presence: yumush.presence_of(member.user.id), |
| 3039 | 3040 | }) |
| @@ -3042,10 +3043,42 @@ fn members_column( | ||
| 3042 | 3043 | let entity = entity.clone(); |
| 3043 | 3044 | let row = |MemberRow { |
| 3044 | 3045 | user, |
| 3046 | + in_voice, | |
| 3045 | 3047 | muted, |
| 3046 | 3048 | presence, |
| 3047 | 3049 | }: &MemberRow| { |
| 3048 | - profile_popover( | |
| 3050 | + let watch = |kind: Kind| { | |
| 3051 | + (*in_voice && chat.share_of(community_id, user.id, kind).is_some()).then(|| { | |
| 3052 | + super::sidebar::watch_pill( | |
| 3053 | + &entity, | |
| 3054 | + user.id, | |
| 3055 | + kind, | |
| 3056 | + yumush.is_watching(user.id, kind), | |
| 3057 | + palette, | |
| 3058 | + ) | |
| 3059 | + }) | |
| 3060 | + }; | |
| 3061 | + let line = in_voice.then(|| { | |
| 3062 | + let speaking = chat.waves.speaking.contains(&user.id); | |
| 3063 | + div() | |
| 3064 | + .w(px(size::CONTROL * 1.5)) | |
| 3065 | + .h(px(space::LG)) | |
| 3066 | + .flex_none() | |
| 3067 | + .child(super::parts::voice_line( | |
| 3068 | + chat.waves.voice(user.id), | |
| 3069 | + if speaking { | |
| 3070 | + super::parts::Voice::Live(palette.tokens.person(user.id)) | |
| 3071 | + } else { | |
| 3072 | + super::parts::Voice::Quiet | |
| 3073 | + }, | |
| 3074 | + palette.tokens, | |
| 3075 | + )) | |
| 3076 | + }); | |
| 3077 | + div() | |
| 3078 | + .flex() | |
| 3079 | + .items_center() | |
| 3080 | + .gap(px(space::XS)) | |
| 3081 | + .child(div().flex_1().min_w_0().child(profile_popover( | |
| 3049 | 3082 | format!("member_{}", user.id), |
| 3050 | 3083 | Anchor::RightCenter, |
| 3051 | 3084 | user, |
| @@ -3083,7 +3116,7 @@ fn members_column( | ||
| 3083 | 3116 | .text_color(palette.danger) |
| 3084 | 3117 | })), |
| 3085 | 3118 | ) |
| 3086 | - .children((!user.status.is_empty()).then(|| { | |
| 3119 | + .children((!user.status.is_empty() && !in_voice).then(|| { | |
| 3087 | 3120 | div() |
| 3088 | 3121 | .text_size(text(text::CAPTION)) |
| 3089 | 3122 | .text_color(palette.muted) |
| @@ -3096,7 +3129,10 @@ fn members_column( | ||
| 3096 | 3129 | ), |
| 3097 | 3130 | palette, |
| 3098 | 3131 | ), |
| 3099 | - ) | |
| 3132 | + ))) | |
| 3133 | + .children(watch(Kind::Camera)) | |
| 3134 | + .children(watch(Kind::Screen)) | |
| 3135 | + .children(line) | |
| 3100 | 3136 | }; |
| 3101 | 3137 | let section = |title: &'static str, rows: Vec<&MemberRow>, cap: usize| { |
| 3102 | 3138 | (!rows.is_empty()).then(|| { |
| @@ -3137,13 +3173,14 @@ fn members_column( | ||
| 3137 | 3173 | }) |
| 3138 | 3174 | }) |
| 3139 | 3175 | }; |
| 3176 | + let in_call = members.iter().filter(|row| row.in_voice).collect(); | |
| 3140 | 3177 | let online = members |
| 3141 | 3178 | .iter() |
| 3142 | - .filter(|row| row.presence != Presence::Offline) | |
| 3179 | + .filter(|row| !row.in_voice && row.presence != Presence::Offline) | |
| 3143 | 3180 | .collect(); |
| 3144 | 3181 | let offline = members |
| 3145 | 3182 | .iter() |
| 3146 | - .filter(|row| row.presence == Presence::Offline) | |
| 3183 | + .filter(|row| !row.in_voice && row.presence == Presence::Offline) | |
| 3147 | 3184 | .collect(); |
| 3148 | 3185 | |
| 3149 | 3186 | Some( |
| @@ -3161,6 +3198,7 @@ fn members_column( | ||
| 3161 | 3198 | .border_l_1() |
| 3162 | 3199 | .border_color(palette.border) |
| 3163 | 3200 | .child(room_head(yumush, palette)) |
| 3201 | + .children(section(w().chat.in_call, in_call, usize::MAX)) | |
| 3164 | 3202 | .children(section(w().chat.online, online, usize::MAX)) |
| 3165 | 3203 | .children(section( |
| 3166 | 3204 | w().chat.offline, |
crates/client/src/gui/sidebar.rsmodified+4 -151
| @@ -222,7 +222,7 @@ impl Yumush { | ||
| 222 | 222 | .into_any_element() |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - fn voice_chip(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> AnyElement { | |
| 225 | + fn voice_chip(&self, community_id: Id, palette: Palette) -> AnyElement { | |
| 226 | 226 | let ids = self.chat.voice_ids(community_id); |
| 227 | 227 | let t = palette.tokens; |
| 228 | 228 | let direct = self.is_direct(community_id); |
| @@ -240,9 +240,6 @@ impl Yumush { | ||
| 240 | 240 | _ => super::parts::Voice::Quiet, |
| 241 | 241 | }; |
| 242 | 242 | let total = self.chat.waves.total(&heard); |
| 243 | - let own = self.chat.voice_community() == Some(community_id); | |
| 244 | - let folded = self.chat.call_folded; | |
| 245 | - let fold = entity.clone(); | |
| 246 | 243 | div() |
| 247 | 244 | .id(format!("voice_chip_{community_id}")) |
| 248 | 245 | .tip(w().sidebar.in_call) |
| @@ -265,146 +262,9 @@ impl Yumush { | ||
| 265 | 262 | .child(ids.len().to_string()), |
| 266 | 263 | ) |
| 267 | 264 | }) |
| 268 | - .when(own && !direct, |this| { | |
| 269 | - this.child( | |
| 270 | - div() | |
| 271 | - .id(format!("call_fold_{community_id}")) | |
| 272 | - .flex_none() | |
| 273 | - .cursor_pointer() | |
| 274 | - .text_color(t.faint()) | |
| 275 | - .hover(|style| style.text_color(t.paper())) | |
| 276 | - .on_click(move |_, _, cx| { | |
| 277 | - cx.stop_propagation(); | |
| 278 | - fold.update(cx, |yumush, cx| { | |
| 279 | - yumush.chat.call_folded = !yumush.chat.call_folded; | |
| 280 | - cx.notify(); | |
| 281 | - }); | |
| 282 | - }) | |
| 283 | - .child( | |
| 284 | - Icon::new(if folded { | |
| 285 | - IconName::ChevronRight | |
| 286 | - } else { | |
| 287 | - IconName::ChevronDown | |
| 288 | - }) | |
| 289 | - .size(px(size::ICON_SM)), | |
| 290 | - ), | |
| 291 | - ) | |
| 292 | - }) | |
| 293 | 265 | .into_any_element() |
| 294 | 266 | } |
| 295 | 267 | |
| 296 | - fn call_tree(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> Option<Div> { | |
| 297 | - if self.chat.voice_community() != Some(community_id) || self.chat.call_folded { | |
| 298 | - return None; | |
| 299 | - } | |
| 300 | - let members = self | |
| 301 | - .chat | |
| 302 | - .voice_ids(community_id) | |
| 303 | - .iter() | |
| 304 | - .filter_map(|id| self.chat.author(*id)) | |
| 305 | - .map(|user| self.call_member(entity, community_id, user, palette)); | |
| 306 | - | |
| 307 | - Some( | |
| 308 | - div() | |
| 309 | - .ml(px(space::LG)) | |
| 310 | - .pl(px(space::MD)) | |
| 311 | - .border_l_1() | |
| 312 | - .border_color(palette.border) | |
| 313 | - .flex() | |
| 314 | - .flex_col() | |
| 315 | - .gap(px(space::XXS)) | |
| 316 | - .mt(px(space::XXS)) | |
| 317 | - .mb(px(space::XS)) | |
| 318 | - .children(members), | |
| 319 | - ) | |
| 320 | - } | |
| 321 | - | |
| 322 | - fn call_member( | |
| 323 | - &self, | |
| 324 | - entity: &Entity<Self>, | |
| 325 | - community_id: Id, | |
| 326 | - user: &User, | |
| 327 | - palette: Palette, | |
| 328 | - ) -> impl IntoElement { | |
| 329 | - let user_id = user.id; | |
| 330 | - let me = self.is_me(user_id); | |
| 331 | - let muted = (me && self.chat.voice_flags().is_some_and(|(muted, _)| muted)) | |
| 332 | - || self.chat.server_muted.contains(&user_id); | |
| 333 | - let speaking = self.chat.waves.speaking.contains(&user_id); | |
| 334 | - let shown = speaking || (me && !muted); | |
| 335 | - let wave = shown.then(|| self.chat.waves.voice(user_id)).flatten(); | |
| 336 | - let camera = self | |
| 337 | - .chat | |
| 338 | - .share_of(community_id, user_id, Kind::Camera) | |
| 339 | - .is_some(); | |
| 340 | - let screen = self | |
| 341 | - .chat | |
| 342 | - .share_of(community_id, user_id, Kind::Screen) | |
| 343 | - .is_some(); | |
| 344 | - let ghost = self.chat.ghost && self.is_me(user_id); | |
| 345 | - | |
| 346 | - let identity = div() | |
| 347 | - .flex() | |
| 348 | - .items_center() | |
| 349 | - .gap(px(space::SM)) | |
| 350 | - .flex_1() | |
| 351 | - .min_w_0() | |
| 352 | - .cursor_pointer() | |
| 353 | - .child( | |
| 354 | - div() | |
| 355 | - .min_w_0() | |
| 356 | - .truncate() | |
| 357 | - .text_size(text(text::LABEL)) | |
| 358 | - .text_color(if speaking { | |
| 359 | - palette.text | |
| 360 | - } else { | |
| 361 | - palette.muted | |
| 362 | - }) | |
| 363 | - .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD)) | |
| 364 | - .child(user.username.clone()), | |
| 365 | - ) | |
| 366 | - .children((muted && wave.is_none()).then(|| { | |
| 367 | - Icon::new(IconName::MicOff) | |
| 368 | - .size(px(size::ICON_SM)) | |
| 369 | - .text_color(palette.danger) | |
| 370 | - })); | |
| 371 | - | |
| 372 | - div() | |
| 373 | - .h(px(size::CONTROL_SM)) | |
| 374 | - .px(px(space::SM)) | |
| 375 | - .rounded(px(radius::MD)) | |
| 376 | - .flex() | |
| 377 | - .items_center() | |
| 378 | - .gap(px(space::SM)) | |
| 379 | - .hover(move |style| style.bg(palette.hover)) | |
| 380 | - .when(ghost, |row| row.text_color(palette.tokens.faint())) | |
| 381 | - .child(div().flex_1().min_w_0().child(profile_popover( | |
| 382 | - format!("call_member_{user_id}"), | |
| 383 | - Anchor::BottomLeft, | |
| 384 | - user, | |
| 385 | - entity, | |
| 386 | - identity, | |
| 387 | - ))) | |
| 388 | - .children(camera.then(|| { | |
| 389 | - watch_pill( | |
| 390 | - entity, | |
| 391 | - user_id, | |
| 392 | - Kind::Camera, | |
| 393 | - self.is_watching(user_id, Kind::Camera), | |
| 394 | - palette, | |
| 395 | - ) | |
| 396 | - })) | |
| 397 | - .children(screen.then(|| { | |
| 398 | - watch_pill( | |
| 399 | - entity, | |
| 400 | - user_id, | |
| 401 | - Kind::Screen, | |
| 402 | - self.is_watching(user_id, Kind::Screen), | |
| 403 | - palette, | |
| 404 | - ) | |
| 405 | - })) | |
| 406 | - } | |
| 407 | - | |
| 408 | 268 | fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> { |
| 409 | 269 | let community = self.chat.voice_room()?; |
| 410 | 270 | |
| @@ -722,14 +582,7 @@ impl Yumush { | ||
| 722 | 582 | self.chat.pinned.contains(&community.id), |
| 723 | 583 | ); |
| 724 | 584 | let row = self.sidebar_community_row(entity, community, palette, "room", menu); |
| 725 | - div() | |
| 726 | - .flex() | |
| 727 | - .flex_col() | |
| 728 | - .child(row) | |
| 729 | - .when(group, |this| { | |
| 730 | - this.children(self.call_tree(entity, community.id, palette)) | |
| 731 | - }) | |
| 732 | - .into_any_element() | |
| 585 | + row.into_any_element() | |
| 733 | 586 | } |
| 734 | 587 | |
| 735 | 588 | fn sidebar_community_row( |
| @@ -757,7 +610,7 @@ impl Yumush { | ||
| 757 | 610 | }) |
| 758 | 611 | }) |
| 759 | 612 | } else { |
| 760 | - Some(self.voice_chip(entity, community_id, palette)) | |
| 613 | + Some(self.voice_chip(community_id, palette)) | |
| 761 | 614 | }; |
| 762 | 615 | let face = match &community.kind { |
| 763 | 616 | CommunityKind::Direct { peer } => Some( |
| @@ -1157,7 +1010,7 @@ fn go_to_call( | ||
| 1157 | 1010 | }) |
| 1158 | 1011 | } |
| 1159 | 1012 | |
| 1160 | -fn watch_pill( | |
| 1013 | +pub(super) fn watch_pill( | |
| 1161 | 1014 | entity: &Entity<Yumush>, |
| 1162 | 1015 | user_id: Id, |
| 1163 | 1016 | kind: Kind, |