forge
Explore
Log in

Don't you dare go Hollow

Places vs people: DM rows carry the person's face (Notes sits in that column as your own), no call count on 1:1 (sidebar and header), People column in a community (In call / Online / Offline) replacing the hidden '2 people' popover, Ctrl+K finds people (friends, members) and opens the DM

Browse files at this commit

9866985f35ad3f89eecb24b8a874626b586beed6Ahmet Kaan GümüşParent: cf604c4
  • feat
    • places vs people: DM rows carry the person's face (Notes sits in that column as your own), no call count on 1:1 (sidebar and header), People column in a community (In call / Online / Offline) replacing the hidden '2 people' popover, Ctrl+K finds people (friends, members) and opens the DM
Show full message
✨ feat: places vs people: DM rows carry the person's face (Notes sits in that column as your own), no call count on 1:1 (sidebar and header), People column in a community (In call / Online / Offline) replacing the hidden '2 people' popover, Ctrl+K finds people (friends, members) and opens the DM
crates/client/src/gui/chat.rsmodified+164 -158
@@ -27,7 +27,7 @@ use crate::gui::{
2727 sidebar::unread_badge,
2828 snippet,
2929 voice_note::{self, VoiceNote},
30- widget::{ok_or_notify, search_text, spawn_done},
30+ widget::{icon_button, ok_or_notify, search_text, spawn_done},
3131 };
3232 use crate::net::Levels;
3333 use crate::settings::VOLUME;
@@ -51,14 +51,12 @@ use common::{
5151 };
5252 use gpui_kit::{
5353 Anchor, AnyElement, App, AppContext, Context, Div, Entity, FontWeight, Image,
54- InteractiveElement, IntoElement, ParentElement, RenderOnce, ScrollHandle,
55- StatefulInteractiveElement, Styled, Subscription, Task, Window,
54+ InteractiveElement, IntoElement, ParentElement, ScrollHandle, StatefulInteractiveElement,
55+ Styled, Subscription, Task, Window,
5656 assets::IconName,
57- base::Selectable,
5857 component::{
5958 Icon, IndexPath, WindowExt,
6059 input::{InputEvent, InputState, Textarea, TextareaState},
61- popover::Popover,
6260 searchable_list::SearchableVec,
6361 select::SelectState,
6462 slider::{SliderEvent, SliderState},
@@ -136,7 +134,7 @@ pub struct Chat {
136134 pub(super) selected_community_id: Option<Id>,
137135 pub(super) opened: Option<Community>,
138136 pub(super) ghost: bool,
139- members: Vec<Member>,
137+ pub(super) members: Vec<Member>,
140138 pub(super) messages: Vec<Message>,
141139 pub(super) pins: Vec<Message>,
142140 history: History,
@@ -269,6 +267,7 @@ pub struct Chat {
269267 pub(super) followed: Option<(Id, common::stats::Stats)>,
270268 pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>,
271269 pub(super) stats_at: Option<StatsAt>,
270+ pub(super) members_open: bool,
272271 pub(super) usage_monitor: crate::usage::Monitor,
273272 pub(super) ringing: HashSet<Id>,
274273 pub(super) ring_task: Option<Task<()>>,
@@ -536,6 +535,7 @@ impl Chat {
536535 followed: None,
537536 share_loss: HashMap::new(),
538537 stats_at: None,
538+ members_open: false,
539539 usage_monitor: {
540540 let monitor = crate::usage::Monitor::default();
541541 if let Some(dir) = crate::config_dir() {
@@ -1320,46 +1320,6 @@ pub(super) fn create_community(
13201320 .detach();
13211321 }
13221322
1323-#[derive(IntoElement)]
1324-struct MembersTrigger {
1325- palette: Palette,
1326- members: Vec<User>,
1327-}
1328-
1329-impl Selectable for MembersTrigger {
1330- fn selected(self, _: bool) -> Self {
1331- self
1332- }
1333-
1334- fn is_selected(&self) -> bool {
1335- false
1336- }
1337-}
1338-
1339-impl RenderOnce for MembersTrigger {
1340- fn render(self, _: &mut Window, _: &mut App) -> impl IntoElement {
1341- let palette = self.palette;
1342-
1343- hoverable(
1344- "members_trigger",
1345- div()
1346- .h(px(size::CONTROL_SM))
1347- .px(px(space::SM))
1348- .flex()
1349- .items_center()
1350- .gap(px(space::SM))
1351- .rounded(px(radius::MD))
1352- .text_size(text(text::LABEL))
1353- .text_color(palette.muted)
1354- .child(match self.members.len() {
1355- 1 => "1 person".to_string(),
1356- count => format!("{count} people"),
1357- }),
1358- palette,
1359- )
1360- }
1361-}
1362-
13631323 impl Yumush {
13641324 pub(super) fn toggle_stats(&mut self, at: StatsAt) {
13651325 self.chat.stats_at = (self.chat.stats_at != Some(at)).then_some(at);
@@ -1419,19 +1379,24 @@ impl Yumush {
14191379 .children(self.stage_strip(entity, themed))
14201380 .children(self.unread_bar(entity, themed))
14211381 .children(self.poll_banner(entity, themed))
1422- .child(div().flex_1().min_h_0().flex().child(
1423- div().flex_1().min_w_0().flex().flex_col().map(|panel| {
1424- match self.inline_viewer(entity, themed) {
1425- Some(viewer) => panel.child(viewer),
1426- None => match self.stage_grid(entity, themed) {
1427- Some(grid) => panel.child(grid),
1428- None => panel
1429- .child(self.message_area(entity, themed))
1430- .child(self.composer(entity, themed, cx)),
1431- },
1432- }
1433- }),
1434- )),
1382+ .child(
1383+ div()
1384+ .flex_1()
1385+ .min_h_0()
1386+ .flex()
1387+ .child(div().flex_1().min_w_0().flex().flex_col().map(|panel| {
1388+ match self.inline_viewer(entity, themed) {
1389+ Some(viewer) => panel.child(viewer),
1390+ None => match self.stage_grid(entity, themed) {
1391+ Some(grid) => panel.child(grid),
1392+ None => panel
1393+ .child(self.message_area(entity, themed))
1394+ .child(self.composer(entity, themed, cx)),
1395+ },
1396+ }
1397+ }))
1398+ .children(members_column(entity, self, themed)),
1399+ ),
14351400 None => panel.child(empty_state(palette)),
14361401 },
14371402 })
@@ -1503,7 +1468,6 @@ impl Yumush {
15031468 super::parts::Ink::Paper,
15041469 palette.tokens,
15051470 ))
1506- .children(group.then(|| members_popover(entity, self, palette)))
15071471 .child(div().flex_1())
15081472 .children(
15091473 community
@@ -1522,6 +1486,21 @@ impl Yumush {
15221486 (community.is_some() && !self.chat.pins.is_empty())
15231487 .then(|| message_actions::pins_popover(&self.chat, entity, palette)),
15241488 )
1489+ .children(group.then(|| {
1490+ icon_button(
1491+ "members_button",
1492+ palette,
1493+ IconName::Users,
1494+ "People",
1495+ entity_action(entity, |yumush, _, cx| {
1496+ yumush.chat.members_open = !yumush.chat.members_open;
1497+ cx.notify();
1498+ }),
1499+ )
1500+ .when(self.chat.members_open, |button| {
1501+ button.text_color(palette.text)
1502+ })
1503+ }))
15251504 }
15261505
15271506 fn message_area(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {
@@ -2734,12 +2713,14 @@ impl Yumush {
27342713 .flex()
27352714 .items_center()
27362715 .gap(px(space::SM))
2737- .child(
2738- div()
2739- .text_size(text(text::LABEL))
2740- .text_color(palette.muted)
2741- .child(format!("{} in call", users.len())),
2742- )
2716+ .when(!self.is_direct(community_id), |stack| {
2717+ stack.child(
2718+ div()
2719+ .text_size(text(text::LABEL))
2720+ .text_color(palette.muted)
2721+ .child(format!("{} in call", users.len())),
2722+ )
2723+ })
27432724 .children(self.in_stage_chat().then(|| {
27442725 div()
27452726 .ml(px(space::SM))
@@ -2780,13 +2761,20 @@ struct MemberRow {
27802761 presence: Presence,
27812762 }
27822763
2783-fn members_popover(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> impl IntoElement {
2764+fn members_column(
2765+ entity: &Entity<Yumush>,
2766+ yumush: &Yumush,
2767+ palette: Palette,
2768+) -> Option<gpui_kit::Stateful<Div>> {
27842769 let chat = &yumush.chat;
2785- let entity = entity.clone();
2786- let voice = chat
2787- .selected_community_id
2788- .map(|community_id| chat.voice_ids(community_id))
2789- .unwrap_or_default();
2770+ let community_id = chat.selected_community_id?;
2771+ let group = chat
2772+ .selected_community()
2773+ .is_some_and(|community| matches!(community.kind, CommunityKind::Group));
2774+ if !chat.members_open || !group {
2775+ return None;
2776+ }
2777+ let voice = chat.voice_ids(community_id);
27902778 let members: Vec<MemberRow> = chat
27912779 .members
27922780 .iter()
@@ -2798,97 +2786,115 @@ fn members_popover(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -
27982786 presence: yumush.presence_of(member.user.id),
27992787 })
28002788 .collect();
2801- let avatars = chat.avatars.clone();
2802-
2803- Popover::new("members_popover")
2804- .anchor(Anchor::TopRight)
2805- .appearance(false)
2806- .trigger(MembersTrigger {
2807- palette,
2808- members: members.iter().map(|row| row.user.clone()).collect(),
2809- })
2810- .content(move |_, _, _| {
2811- let entity = entity.clone();
2812-
2813- div()
2814- .w(px(size::SIDEBAR))
2815- .p(px(space::XS))
2816- .flex()
2817- .flex_col()
2818- .rounded(px(radius::LG))
2819- .bg(palette.field)
2820- .children(members.iter().map(
2821- |MemberRow {
2822- user,
2823- rank,
2824- in_voice,
2825- muted,
2826- presence,
2827- }| {
2828- profile_popover(
2829- format!("member_{}", user.id),
2830- Anchor::TopRight,
2831- user,
2832- &entity,
2833- hoverable(
2834- format!("member_trigger_{}", user.id),
2789+ let avatars = &chat.avatars;
2790+ let entity = entity.clone();
2791+ let row = |MemberRow {
2792+ user,
2793+ rank,
2794+ in_voice,
2795+ muted,
2796+ presence,
2797+ }: &MemberRow| {
2798+ profile_popover(
2799+ format!("member_{}", user.id),
2800+ Anchor::TopRight,
2801+ user,
2802+ &entity,
2803+ hoverable(
2804+ format!("member_trigger_{}", user.id),
2805+ div()
2806+ .h(px(size::CONTROL))
2807+ .px(px(space::SM))
2808+ .flex()
2809+ .items_center()
2810+ .gap(px(space::SM))
2811+ .rounded(px(radius::MD))
2812+ .child(presence_avatar(
2813+ avatar(palette, user, px(size::ICON), text(text::CAPTION), &avatars),
2814+ *presence,
2815+ px(size::ICON),
2816+ palette,
2817+ ))
2818+ .child(
2819+ div()
2820+ .flex_1()
2821+ .min_w_0()
2822+ .flex()
2823+ .flex_col()
2824+ .child(
28352825 div()
2836- .h(px(size::CONTROL))
2837- .px(px(space::SM))
28382826 .flex()
28392827 .items_center()
28402828 .gap(px(space::SM))
2841- .rounded(px(radius::MD))
2842- .child(presence_avatar(
2843- avatar(
2844- palette,
2845- user,
2846- px(size::ICON),
2847- text(text::CAPTION),
2848- &avatars,
2849- ),
2850- *presence,
2851- px(size::ICON),
2852- palette,
2853- ))
2854- .child(
2855- div()
2856- .flex_1()
2857- .min_w_0()
2858- .flex()
2859- .flex_col()
2860- .child(
2861- div()
2862- .flex()
2863- .items_center()
2864- .gap(px(space::SM))
2865- .child(user.username.clone())
2866- .children(rank_tag(*rank, palette))
2867- .children(in_voice.then(|| {
2868- Icon::new(IconName::Headphones)
2869- .size(px(size::ICON_SM))
2870- .text_color(palette.muted)
2871- }))
2872- .children(muted.then(|| {
2873- Icon::new(IconName::MicOff)
2874- .size(px(size::ICON_SM))
2875- .text_color(palette.danger)
2876- })),
2877- )
2878- .children((!user.status.is_empty()).then(|| {
2879- div()
2880- .text_size(text(text::CAPTION))
2881- .text_color(palette.muted)
2882- .truncate()
2883- .child(user.status.clone())
2884- })),
2885- ),
2886- palette,
2887- ),
2888- )
2889- },
2890- ))
2829+ .child(user.username.clone())
2830+ .children(rank_tag(*rank, palette))
2831+ .children(in_voice.then(|| {
2832+ Icon::new(IconName::Headphones)
2833+ .size(px(size::ICON_SM))
2834+ .text_color(palette.muted)
2835+ }))
2836+ .children(muted.then(|| {
2837+ Icon::new(IconName::MicOff)
2838+ .size(px(size::ICON_SM))
2839+ .text_color(palette.danger)
2840+ })),
2841+ )
2842+ .children((!user.status.is_empty()).then(|| {
2843+ div()
2844+ .text_size(text(text::CAPTION))
2845+ .text_color(palette.muted)
2846+ .truncate()
2847+ .child(user.status.clone())
2848+ })),
2849+ ),
2850+ palette,
2851+ ),
2852+ )
2853+ };
2854+ let section = |title: &'static str, rows: Vec<&MemberRow>| {
2855+ (!rows.is_empty()).then(|| {
2856+ div()
2857+ .flex()
2858+ .flex_col()
2859+ .child(
2860+ div()
2861+ .px(px(space::SM))
2862+ .pb(px(space::XS))
2863+ .text_size(text(text::CAPTION))
2864+ .text_color(palette.muted)
2865+ .child(format!("{title} · {}", rows.len())),
2866+ )
2867+ .children(rows.into_iter().map(row))
28912868 })
2869+ };
2870+ let in_call = members.iter().filter(|row| row.in_voice).collect();
2871+ let online = members
2872+ .iter()
2873+ .filter(|row| !row.in_voice && row.presence != Presence::Offline)
2874+ .collect();
2875+ let offline = members
2876+ .iter()
2877+ .filter(|row| !row.in_voice && row.presence == Presence::Offline)
2878+ .collect();
2879+
2880+ Some(
2881+ div()
2882+ .id("members_column")
2883+ .w(px(size::SIDEBAR))
2884+ .flex_none()
2885+ .h_full()
2886+ .overflow_y_scroll()
2887+ .px(px(space::SM))
2888+ .py(px(space::MD))
2889+ .flex()
2890+ .flex_col()
2891+ .gap(px(space::LG))
2892+ .border_l_1()
2893+ .border_color(palette.border)
2894+ .children(section("In call", in_call))
2895+ .children(section("Online", online))
2896+ .children(section("Offline", offline)),
2897+ )
28922898 }
28932899
28942900 fn accent_bar(palette: Palette) -> Div {
crates/client/src/gui/jump.rsmodified+31 -2
@@ -21,6 +21,7 @@ const SHOWN: usize = 8;
2121 #[derive(Clone, Copy, PartialEq)]
2222 pub(super) enum Place {
2323 Room(Id),
24+ Person(Id),
2425 Notes,
2526 Friends,
2627 Settings(usize),
@@ -52,9 +53,9 @@ impl Yumush {
5253 rooms.sort_by_key(|community| (Some(community.id) != call, !unread(community.id)));
5354 let rooms = rooms.into_iter().map(|community| {
5455 let hint = if community.kind.is_direct() {
55- "direct"
56+ "person"
5657 } else {
57- "room"
58+ "community"
5859 };
5960 (
6061 Place::Room(community.id),
@@ -62,6 +63,29 @@ impl Yumush {
6263 hint,
6364 )
6465 });
66+ let directs: Vec<Id> = self
67+ .chat
68+ .communities
69+ .iter()
70+ .filter_map(|community| match &community.kind {
71+ CommunityKind::Direct { peer } => Some(peer.id),
72+ _ => None,
73+ })
74+ .collect();
75+ let mut seen = std::collections::HashSet::new();
76+ let people = self
77+ .chat
78+ .friends
79+ .friends
80+ .iter()
81+ .chain(self.chat.members.iter().map(|member| &member.user))
82+ .filter(|user| {
83+ !directs.contains(&user.id)
84+ && self.user.as_ref().is_none_or(|me| me.id != user.id)
85+ && seen.insert(user.id)
86+ })
87+ .map(|user| (Place::Person(user.id), user.username.to_string(), "person"))
88+ .collect::<Vec<_>>();
6589 let pages = [
6690 (Place::Notes, "Notes".to_string(), "page"),
6791 (Place::Friends, "Friends".to_string(), "page"),
@@ -80,6 +104,7 @@ impl Yumush {
80104 .map(|tab| (Place::Builder(tab), tab.label().to_string(), "builder")),
81105 );
82106 rooms
107+ .chain(people)
83108 .chain(pages)
84109 .filter(|(_, label, _)| label.to_lowercase().contains(&query))
85110 .take(SHOWN)
@@ -128,6 +153,10 @@ impl Yumush {
128153 self.show_view(View::Chat, window, cx);
129154 self.select_community(id, window, cx);
130155 }
156+ Place::Person(id) => {
157+ self.show_view(View::Chat, window, cx);
158+ self.open_direct(id, window, cx);
159+ }
131160 Place::Notes => self.open_notes(window, cx),
132161 Place::Friends => self.show_view(View::Friends, window, cx),
133162 Place::Settings(index) => {
crates/client/src/gui/sidebar.rsmodified+35 -10
@@ -194,12 +194,14 @@ impl Yumush {
194194 .child(super::parts::voice_line(wave, voice, palette.tokens)),
195195 )
196196 })
197- .child(
198- div()
199- .text_size(text(text::CAPTION))
200- .text_color(palette.muted)
201- .child(ids.len().to_string()),
202- )
197+ .when(!self.is_direct(community_id), |this| {
198+ this.child(
199+ div()
200+ .text_size(text(text::CAPTION))
201+ .text_color(palette.muted)
202+ .child(ids.len().to_string()),
203+ )
204+ })
203205 .into_any_element()
204206 }
205207
@@ -449,9 +451,16 @@ impl Yumush {
449451 entry(
450452 palette,
451453 active,
452- Icon::new(IconName::Bookmark)
453- .size(px(size::ICON))
454- .text_color(palette.accent),
454+ div()
455+ .size(px(size::AVATAR))
456+ .flex()
457+ .items_center()
458+ .justify_center()
459+ .child(
460+ Icon::new(IconName::Bookmark)
461+ .size(px(size::ICON_SM))
462+ .text_color(palette.accent),
463+ ),
455464 "Notes",
456465 unread_badge(palette, false, unread),
457466 ),
@@ -527,6 +536,21 @@ impl Yumush {
527536 } else {
528537 Some(self.voice_chip(community_id, palette))
529538 };
539+ let face = match &community.kind {
540+ CommunityKind::Direct { peer } => Some(presence_avatar(
541+ avatar(
542+ palette,
543+ peer,
544+ px(size::AVATAR),
545+ text(text::CAPTION),
546+ &self.chat.avatars,
547+ ),
548+ self.presence_of(peer.id),
549+ px(size::AVATAR),
550+ palette,
551+ )),
552+ CommunityKind::Group | CommunityKind::Notes => None,
553+ };
530554 hoverable(
531555 format!("{key}_{}", community.id),
532556 div()
@@ -535,9 +559,10 @@ impl Yumush {
535559 .rounded(px(radius::MD))
536560 .flex()
537561 .items_center()
538- .gap(px(space::XS))
562+ .gap(px(space::SM))
539563 .text_color(if active { palette.text } else { palette.muted })
540564 .when(active, |row| row.font_weight(FontWeight::MEDIUM))
565+ .children(face)
541566 .child(
542567 div()
543568 .min_w_0()