forge
Explore
Log in

Don't you dare go Hollow

Call people live in the room margin (In call with voice lines and watch buttons)

Browse files at this commit

153c8a91cf5febcd3953e4d8ed3954bc94e4f2baAhmet Kaan GümüşParent: 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
Show full message
💄 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
crates/client/lang/en/chat.txtmodified+1 -0
@@ -60,3 +60,4 @@ call_declined = {name} declined the call
6060 call_missed_mine = You called, no answer
6161 call_missed = Missed call from {name}
6262 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
6060 call_missed_mine = Aradın, cevap yok
6161 call_missed = Cevapsız arama: {name}
6262 call_ended = Arama bitti · {duration}
63+in_call = Aramada
crates/client/src/gui/chat.rsmodified+46 -8
@@ -134,7 +134,6 @@ pub struct Chat {
134134 pub(super) selected_community_id: Option<Id>,
135135 pub(super) opened: Option<Community>,
136136 pub(super) ghost: bool,
137- pub(super) call_folded: bool,
138137 pub(super) members: Vec<Member>,
139138 pub(super) messages: Vec<Message>,
140139 pub(super) pins: Vec<Message>,
@@ -395,7 +394,6 @@ impl Chat {
395394 selected_community_id: None,
396395 opened: None,
397396 ghost: false,
398- call_folded: false,
399397 members: vec![],
400398 bans: vec![],
401399 ban_search,
@@ -3012,6 +3010,7 @@ impl Yumush {
30123010
30133011 struct MemberRow {
30143012 user: User,
3013+ in_voice: bool,
30153014 muted: bool,
30163015 presence: Presence,
30173016 }
@@ -3022,18 +3021,20 @@ fn members_column(
30223021 palette: Palette,
30233022 ) -> Option<gpui_kit::Stateful<Div>> {
30243023 let chat = &yumush.chat;
3025- chat.selected_community_id?;
3024+ let community_id = chat.selected_community_id?;
30263025 let group = chat
30273026 .selected_community()
30283027 .is_some_and(|community| matches!(community.kind, CommunityKind::Group));
30293028 if !chat.members_open || !group {
30303029 return None;
30313030 }
3031+ let voice = chat.voice_ids(community_id);
30323032 let members: Vec<MemberRow> = chat
30333033 .members
30343034 .iter()
30353035 .map(|member| MemberRow {
30363036 user: member.user.clone(),
3037+ in_voice: voice.contains(&member.user.id),
30373038 muted: chat.server_muted.contains(&member.user.id),
30383039 presence: yumush.presence_of(member.user.id),
30393040 })
@@ -3042,10 +3043,42 @@ fn members_column(
30423043 let entity = entity.clone();
30433044 let row = |MemberRow {
30443045 user,
3046+ in_voice,
30453047 muted,
30463048 presence,
30473049 }: &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(
30493082 format!("member_{}", user.id),
30503083 Anchor::RightCenter,
30513084 user,
@@ -3083,7 +3116,7 @@ fn members_column(
30833116 .text_color(palette.danger)
30843117 })),
30853118 )
3086- .children((!user.status.is_empty()).then(|| {
3119+ .children((!user.status.is_empty() && !in_voice).then(|| {
30873120 div()
30883121 .text_size(text(text::CAPTION))
30893122 .text_color(palette.muted)
@@ -3096,7 +3129,10 @@ fn members_column(
30963129 ),
30973130 palette,
30983131 ),
3099- )
3132+ )))
3133+ .children(watch(Kind::Camera))
3134+ .children(watch(Kind::Screen))
3135+ .children(line)
31003136 };
31013137 let section = |title: &'static str, rows: Vec<&MemberRow>, cap: usize| {
31023138 (!rows.is_empty()).then(|| {
@@ -3137,13 +3173,14 @@ fn members_column(
31373173 })
31383174 })
31393175 };
3176+ let in_call = members.iter().filter(|row| row.in_voice).collect();
31403177 let online = members
31413178 .iter()
3142- .filter(|row| row.presence != Presence::Offline)
3179+ .filter(|row| !row.in_voice && row.presence != Presence::Offline)
31433180 .collect();
31443181 let offline = members
31453182 .iter()
3146- .filter(|row| row.presence == Presence::Offline)
3183+ .filter(|row| !row.in_voice && row.presence == Presence::Offline)
31473184 .collect();
31483185
31493186 Some(
@@ -3161,6 +3198,7 @@ fn members_column(
31613198 .border_l_1()
31623199 .border_color(palette.border)
31633200 .child(room_head(yumush, palette))
3201+ .children(section(w().chat.in_call, in_call, usize::MAX))
31643202 .children(section(w().chat.online, online, usize::MAX))
31653203 .children(section(
31663204 w().chat.offline,
crates/client/src/gui/sidebar.rsmodified+4 -151
@@ -222,7 +222,7 @@ impl Yumush {
222222 .into_any_element()
223223 }
224224
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 {
226226 let ids = self.chat.voice_ids(community_id);
227227 let t = palette.tokens;
228228 let direct = self.is_direct(community_id);
@@ -240,9 +240,6 @@ impl Yumush {
240240 _ => super::parts::Voice::Quiet,
241241 };
242242 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();
246243 div()
247244 .id(format!("voice_chip_{community_id}"))
248245 .tip(w().sidebar.in_call)
@@ -265,146 +262,9 @@ impl Yumush {
265262 .child(ids.len().to_string()),
266263 )
267264 })
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- })
293265 .into_any_element()
294266 }
295267
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-
408268 fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> {
409269 let community = self.chat.voice_room()?;
410270
@@ -722,14 +582,7 @@ impl Yumush {
722582 self.chat.pinned.contains(&community.id),
723583 );
724584 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()
733586 }
734587
735588 fn sidebar_community_row(
@@ -757,7 +610,7 @@ impl Yumush {
757610 })
758611 })
759612 } else {
760- Some(self.voice_chip(entity, community_id, palette))
613+ Some(self.voice_chip(community_id, palette))
761614 };
762615 let face = match &community.kind {
763616 CommunityKind::Direct { peer } => Some(
@@ -1157,7 +1010,7 @@ fn go_to_call(
11571010 })
11581011 }
11591012
1160-fn watch_pill(
1013+pub(super) fn watch_pill(
11611014 entity: &Entity<Yumush>,
11621015 user_id: Id,
11631016 kind: Kind,