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::{
27 sidebar::unread_badge,27 sidebar::unread_badge,
28 snippet,28 snippet,
29 voice_note::{self, VoiceNote},29 voice_note::{self, VoiceNote},
30- widget::{ok_or_notify, search_text, spawn_done},30+ widget::{icon_button, ok_or_notify, search_text, spawn_done},
31 };31 };
32 use crate::net::Levels;32 use crate::net::Levels;
33 use crate::settings::VOLUME;33 use crate::settings::VOLUME;
@@ -51,14 +51,12 @@ use common::{
51 };51 };
52 use gpui_kit::{52 use gpui_kit::{
53 Anchor, AnyElement, App, AppContext, Context, Div, Entity, FontWeight, Image,53 Anchor, AnyElement, App, AppContext, Context, Div, Entity, FontWeight, Image,
54- InteractiveElement, IntoElement, ParentElement, RenderOnce, ScrollHandle,54+ InteractiveElement, IntoElement, ParentElement, ScrollHandle, StatefulInteractiveElement,
55- StatefulInteractiveElement, Styled, Subscription, Task, Window,55+ Styled, Subscription, Task, Window,
56 assets::IconName,56 assets::IconName,
57- base::Selectable,
58 component::{57 component::{
59 Icon, IndexPath, WindowExt,58 Icon, IndexPath, WindowExt,
60 input::{InputEvent, InputState, Textarea, TextareaState},59 input::{InputEvent, InputState, Textarea, TextareaState},
61- popover::Popover,
62 searchable_list::SearchableVec,60 searchable_list::SearchableVec,
63 select::SelectState,61 select::SelectState,
64 slider::{SliderEvent, SliderState},62 slider::{SliderEvent, SliderState},
@@ -136,7 +134,7 @@ pub struct Chat {
136 pub(super) selected_community_id: Option<Id>,134 pub(super) selected_community_id: Option<Id>,
137 pub(super) opened: Option<Community>,135 pub(super) opened: Option<Community>,
138 pub(super) ghost: bool,136 pub(super) ghost: bool,
139- members: Vec<Member>,137+ pub(super) members: Vec<Member>,
140 pub(super) messages: Vec<Message>,138 pub(super) messages: Vec<Message>,
141 pub(super) pins: Vec<Message>,139 pub(super) pins: Vec<Message>,
142 history: History,140 history: History,
@@ -269,6 +267,7 @@ pub struct Chat {
269 pub(super) followed: Option<(Id, common::stats::Stats)>,267 pub(super) followed: Option<(Id, common::stats::Stats)>,
270 pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>,268 pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>,
271 pub(super) stats_at: Option<StatsAt>,269 pub(super) stats_at: Option<StatsAt>,
270+ pub(super) members_open: bool,
272 pub(super) usage_monitor: crate::usage::Monitor,271 pub(super) usage_monitor: crate::usage::Monitor,
273 pub(super) ringing: HashSet<Id>,272 pub(super) ringing: HashSet<Id>,
274 pub(super) ring_task: Option<Task<()>>,273 pub(super) ring_task: Option<Task<()>>,
@@ -536,6 +535,7 @@ impl Chat {
536 followed: None,535 followed: None,
537 share_loss: HashMap::new(),536 share_loss: HashMap::new(),
538 stats_at: None,537 stats_at: None,
538+ members_open: false,
539 usage_monitor: {539 usage_monitor: {
540 let monitor = crate::usage::Monitor::default();540 let monitor = crate::usage::Monitor::default();
541 if let Some(dir) = crate::config_dir() {541 if let Some(dir) = crate::config_dir() {
@@ -1320,46 +1320,6 @@ pub(super) fn create_community(
1320 .detach();1320 .detach();
1321 }1321 }
1322 1322
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-
1363 impl Yumush {1323 impl Yumush {
1364 pub(super) fn toggle_stats(&mut self, at: StatsAt) {1324 pub(super) fn toggle_stats(&mut self, at: StatsAt) {
1365 self.chat.stats_at = (self.chat.stats_at != Some(at)).then_some(at);1325 self.chat.stats_at = (self.chat.stats_at != Some(at)).then_some(at);
@@ -1419,19 +1379,24 @@ impl Yumush {
1419 .children(self.stage_strip(entity, themed))1379 .children(self.stage_strip(entity, themed))
1420 .children(self.unread_bar(entity, themed))1380 .children(self.unread_bar(entity, themed))
1421 .children(self.poll_banner(entity, themed))1381 .children(self.poll_banner(entity, themed))
1422- .child(div().flex_1().min_h_0().flex().child(1382+ .child(
1423- div().flex_1().min_w_0().flex().flex_col().map(|panel| {1383+ div()
1424- match self.inline_viewer(entity, themed) {1384+ .flex_1()
1425- Some(viewer) => panel.child(viewer),1385+ .min_h_0()
1426- None => match self.stage_grid(entity, themed) {1386+ .flex()
1427- Some(grid) => panel.child(grid),1387+ .child(div().flex_1().min_w_0().flex().flex_col().map(|panel| {
1428- None => panel1388+ match self.inline_viewer(entity, themed) {
1429- .child(self.message_area(entity, themed))1389+ Some(viewer) => panel.child(viewer),
1430- .child(self.composer(entity, themed, cx)),1390+ None => match self.stage_grid(entity, themed) {
1431- },1391+ Some(grid) => panel.child(grid),
1432- }1392+ None => panel
1433- }),1393+ .child(self.message_area(entity, themed))
1434- )),1394+ .child(self.composer(entity, themed, cx)),
1395+ },
1396+ }
1397+ }))
1398+ .children(members_column(entity, self, themed)),
1399+ ),
1435 None => panel.child(empty_state(palette)),1400 None => panel.child(empty_state(palette)),
1436 },1401 },
1437 })1402 })
@@ -1503,7 +1468,6 @@ impl Yumush {
1503 super::parts::Ink::Paper,1468 super::parts::Ink::Paper,
1504 palette.tokens,1469 palette.tokens,
1505 ))1470 ))
1506- .children(group.then(|| members_popover(entity, self, palette)))
1507 .child(div().flex_1())1471 .child(div().flex_1())
1508 .children(1472 .children(
1509 community1473 community
@@ -1522,6 +1486,21 @@ impl Yumush {
1522 (community.is_some() && !self.chat.pins.is_empty())1486 (community.is_some() && !self.chat.pins.is_empty())
1523 .then(|| message_actions::pins_popover(&self.chat, entity, palette)),1487 .then(|| message_actions::pins_popover(&self.chat, entity, palette)),
1524 )1488 )
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+ }))
1525 }1504 }
1526 1505
1527 fn message_area(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {1506 fn message_area(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {
@@ -2734,12 +2713,14 @@ impl Yumush {
2734 .flex()2713 .flex()
2735 .items_center()2714 .items_center()
2736 .gap(px(space::SM))2715 .gap(px(space::SM))
2737- .child(2716+ .when(!self.is_direct(community_id), |stack| {
2738- div()2717+ stack.child(
2739- .text_size(text(text::LABEL))2718+ div()
2740- .text_color(palette.muted)2719+ .text_size(text(text::LABEL))
2741- .child(format!("{} in call", users.len())),2720+ .text_color(palette.muted)
2742- )2721+ .child(format!("{} in call", users.len())),
2722+ )
2723+ })
2743 .children(self.in_stage_chat().then(|| {2724 .children(self.in_stage_chat().then(|| {
2744 div()2725 div()
2745 .ml(px(space::SM))2726 .ml(px(space::SM))
@@ -2780,13 +2761,20 @@ struct MemberRow {
2780 presence: Presence,2761 presence: Presence,
2781 }2762 }
2782 2763
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>> {
2784 let chat = &yumush.chat;2769 let chat = &yumush.chat;
2785- let entity = entity.clone();2770+ let community_id = chat.selected_community_id?;
2786- let voice = chat2771+ let group = chat
2787- .selected_community_id2772+ .selected_community()
2788- .map(|community_id| chat.voice_ids(community_id))2773+ .is_some_and(|community| matches!(community.kind, CommunityKind::Group));
2789- .unwrap_or_default();2774+ if !chat.members_open || !group {
2775+ return None;
2776+ }
2777+ let voice = chat.voice_ids(community_id);
2790 let members: Vec<MemberRow> = chat2778 let members: Vec<MemberRow> = chat
2791 .members2779 .members
2792 .iter()2780 .iter()
@@ -2798,97 +2786,115 @@ fn members_popover(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -
2798 presence: yumush.presence_of(member.user.id),2786 presence: yumush.presence_of(member.user.id),
2799 })2787 })
2800 .collect();2788 .collect();
2801- let avatars = chat.avatars.clone();2789+ let avatars = &chat.avatars;
2802-2790+ let entity = entity.clone();
2803- Popover::new("members_popover")2791+ let row = |MemberRow {
2804- .anchor(Anchor::TopRight)2792+ user,
2805- .appearance(false)2793+ rank,
2806- .trigger(MembersTrigger {2794+ in_voice,
2807- palette,2795+ muted,
2808- members: members.iter().map(|row| row.user.clone()).collect(),2796+ presence,
2809- })2797+ }: &MemberRow| {
2810- .content(move |_, _, _| {2798+ profile_popover(
2811- let entity = entity.clone();2799+ format!("member_{}", user.id),
2812-2800+ Anchor::TopRight,
2813- div()2801+ user,
2814- .w(px(size::SIDEBAR))2802+ &entity,
2815- .p(px(space::XS))2803+ hoverable(
2816- .flex()2804+ format!("member_trigger_{}", user.id),
2817- .flex_col()2805+ div()
2818- .rounded(px(radius::LG))2806+ .h(px(size::CONTROL))
2819- .bg(palette.field)2807+ .px(px(space::SM))
2820- .children(members.iter().map(2808+ .flex()
2821- |MemberRow {2809+ .items_center()
2822- user,2810+ .gap(px(space::SM))
2823- rank,2811+ .rounded(px(radius::MD))
2824- in_voice,2812+ .child(presence_avatar(
2825- muted,2813+ avatar(palette, user, px(size::ICON), text(text::CAPTION), &avatars),
2826- presence,2814+ *presence,
2827- }| {2815+ px(size::ICON),
2828- profile_popover(2816+ palette,
2829- format!("member_{}", user.id),2817+ ))
2830- Anchor::TopRight,2818+ .child(
2831- user,2819+ div()
2832- &entity,2820+ .flex_1()
2833- hoverable(2821+ .min_w_0()
2834- format!("member_trigger_{}", user.id),2822+ .flex()
2823+ .flex_col()
2824+ .child(
2835 div()2825 div()
2836- .h(px(size::CONTROL))
2837- .px(px(space::SM))
2838 .flex()2826 .flex()
2839 .items_center()2827 .items_center()
2840 .gap(px(space::SM))2828 .gap(px(space::SM))
2841- .rounded(px(radius::MD))2829+ .child(user.username.clone())
2842- .child(presence_avatar(2830+ .children(rank_tag(*rank, palette))
2843- avatar(2831+ .children(in_voice.then(|| {
2844- palette,2832+ Icon::new(IconName::Headphones)
2845- user,2833+ .size(px(size::ICON_SM))
2846- px(size::ICON),2834+ .text_color(palette.muted)
2847- text(text::CAPTION),2835+ }))
2848- &avatars,2836+ .children(muted.then(|| {
2849- ),2837+ Icon::new(IconName::MicOff)
2850- *presence,2838+ .size(px(size::ICON_SM))
2851- px(size::ICON),2839+ .text_color(palette.danger)
2852- palette,2840+ })),
2853- ))2841+ )
2854- .child(2842+ .children((!user.status.is_empty()).then(|| {
2855- div()2843+ div()
2856- .flex_1()2844+ .text_size(text(text::CAPTION))
2857- .min_w_0()2845+ .text_color(palette.muted)
2858- .flex()2846+ .truncate()
2859- .flex_col()2847+ .child(user.status.clone())
2860- .child(2848+ })),
2861- div()2849+ ),
2862- .flex()2850+ palette,
2863- .items_center()2851+ ),
2864- .gap(px(space::SM))2852+ )
2865- .child(user.username.clone())2853+ };
2866- .children(rank_tag(*rank, palette))2854+ let section = |title: &'static str, rows: Vec<&MemberRow>| {
2867- .children(in_voice.then(|| {2855+ (!rows.is_empty()).then(|| {
2868- Icon::new(IconName::Headphones)2856+ div()
2869- .size(px(size::ICON_SM))2857+ .flex()
2870- .text_color(palette.muted)2858+ .flex_col()
2871- }))2859+ .child(
2872- .children(muted.then(|| {2860+ div()
2873- Icon::new(IconName::MicOff)2861+ .px(px(space::SM))
2874- .size(px(size::ICON_SM))2862+ .pb(px(space::XS))
2875- .text_color(palette.danger)2863+ .text_size(text(text::CAPTION))
2876- })),2864+ .text_color(palette.muted)
2877- )2865+ .child(format!("{title} · {}", rows.len())),
2878- .children((!user.status.is_empty()).then(|| {2866+ )
2879- div()2867+ .children(rows.into_iter().map(row))
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- ))
2891 })2868 })
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+ )
2892 }2898 }
2893 2899
2894 fn accent_bar(palette: Palette) -> Div {2900 fn accent_bar(palette: Palette) -> Div {
crates/client/src/gui/jump.rsmodified+31 -2
@@ -21,6 +21,7 @@ const SHOWN: usize = 8;
21 #[derive(Clone, Copy, PartialEq)]21 #[derive(Clone, Copy, PartialEq)]
22 pub(super) enum Place {22 pub(super) enum Place {
23 Room(Id),23 Room(Id),
24+ Person(Id),
24 Notes,25 Notes,
25 Friends,26 Friends,
26 Settings(usize),27 Settings(usize),
@@ -52,9 +53,9 @@ impl Yumush {
52 rooms.sort_by_key(|community| (Some(community.id) != call, !unread(community.id)));53 rooms.sort_by_key(|community| (Some(community.id) != call, !unread(community.id)));
53 let rooms = rooms.into_iter().map(|community| {54 let rooms = rooms.into_iter().map(|community| {
54 let hint = if community.kind.is_direct() {55 let hint = if community.kind.is_direct() {
55- "direct"56+ "person"
56 } else {57 } else {
57- "room"58+ "community"
58 };59 };
59 (60 (
60 Place::Room(community.id),61 Place::Room(community.id),
@@ -62,6 +63,29 @@ impl Yumush {
62 hint,63 hint,
63 )64 )
64 });65 });
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<_>>();
65 let pages = [89 let pages = [
66 (Place::Notes, "Notes".to_string(), "page"),90 (Place::Notes, "Notes".to_string(), "page"),
67 (Place::Friends, "Friends".to_string(), "page"),91 (Place::Friends, "Friends".to_string(), "page"),
@@ -80,6 +104,7 @@ impl Yumush {
80 .map(|tab| (Place::Builder(tab), tab.label().to_string(), "builder")),104 .map(|tab| (Place::Builder(tab), tab.label().to_string(), "builder")),
81 );105 );
82 rooms106 rooms
107+ .chain(people)
83 .chain(pages)108 .chain(pages)
84 .filter(|(_, label, _)| label.to_lowercase().contains(&query))109 .filter(|(_, label, _)| label.to_lowercase().contains(&query))
85 .take(SHOWN)110 .take(SHOWN)
@@ -128,6 +153,10 @@ impl Yumush {
128 self.show_view(View::Chat, window, cx);153 self.show_view(View::Chat, window, cx);
129 self.select_community(id, window, cx);154 self.select_community(id, window, cx);
130 }155 }
156+ Place::Person(id) => {
157+ self.show_view(View::Chat, window, cx);
158+ self.open_direct(id, window, cx);
159+ }
131 Place::Notes => self.open_notes(window, cx),160 Place::Notes => self.open_notes(window, cx),
132 Place::Friends => self.show_view(View::Friends, window, cx),161 Place::Friends => self.show_view(View::Friends, window, cx),
133 Place::Settings(index) => {162 Place::Settings(index) => {
crates/client/src/gui/sidebar.rsmodified+35 -10
@@ -194,12 +194,14 @@ impl Yumush {
194 .child(super::parts::voice_line(wave, voice, palette.tokens)),194 .child(super::parts::voice_line(wave, voice, palette.tokens)),
195 )195 )
196 })196 })
197- .child(197+ .when(!self.is_direct(community_id), |this| {
198- div()198+ this.child(
199- .text_size(text(text::CAPTION))199+ div()
200- .text_color(palette.muted)200+ .text_size(text(text::CAPTION))
201- .child(ids.len().to_string()),201+ .text_color(palette.muted)
202- )202+ .child(ids.len().to_string()),
203+ )
204+ })
203 .into_any_element()205 .into_any_element()
204 }206 }
205 207
@@ -449,9 +451,16 @@ impl Yumush {
449 entry(451 entry(
450 palette,452 palette,
451 active,453 active,
452- Icon::new(IconName::Bookmark)454+ div()
453- .size(px(size::ICON))455+ .size(px(size::AVATAR))
454- .text_color(palette.accent),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+ ),
455 "Notes",464 "Notes",
456 unread_badge(palette, false, unread),465 unread_badge(palette, false, unread),
457 ),466 ),
@@ -527,6 +536,21 @@ impl Yumush {
527 } else {536 } else {
528 Some(self.voice_chip(community_id, palette))537 Some(self.voice_chip(community_id, palette))
529 };538 };
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+ };
530 hoverable(554 hoverable(
531 format!("{key}_{}", community.id),555 format!("{key}_{}", community.id),
532 div()556 div()
@@ -535,9 +559,10 @@ impl Yumush {
535 .rounded(px(radius::MD))559 .rounded(px(radius::MD))
536 .flex()560 .flex()
537 .items_center()561 .items_center()
538- .gap(px(space::XS))562+ .gap(px(space::SM))
539 .text_color(if active { palette.text } else { palette.muted })563 .text_color(if active { palette.text } else { palette.muted })
540 .when(active, |row| row.font_weight(FontWeight::MEDIUM))564 .when(active, |row| row.font_weight(FontWeight::MEDIUM))
565+ .children(face)
541 .child(566 .child(
542 div()567 div()
543 .min_w_0()568 .min_w_0()