forge
Explore
Log in

Don't you dare go Hollow

SSOT pass: one icon_button (Scale), parts::caption_head, CommunityKind::is_group/peer, Yumush::is_online, shared lang words in common

Browse files at this commit

5d0b33a68782a7e58a20ddefde6267f2e84b1b18Ahmet Kaan GümüşParent: 1119c75
  • refactor
    • SSOT pass: one icon_button (Scale), parts::caption_head, CommunityKind::is_group/peer, Yumush::is_online, shared lang words in common
Show full message
♻️ refactor: SSOT pass: one icon_button (Scale), parts::caption_head, CommunityKind::is_group/peer, Yumush::is_online, shared lang words in common
crates/client/lang/en/builder.txtmodified+0 -1
@@ -1,7 +1,6 @@
1 overview = Overview1 overview = Overview
2 users = Users2 users = Users
3 communities = Communities3 communities = Communities
4-messages = Messages
5 voice = Voice4 voice = Voice
6 storage = Storage5 storage = Storage
7 access = Access6 access = Access
crates/client/lang/en/builder_access.txtmodified+0 -1
@@ -9,4 +9,3 @@ create = Create
9 invite_codes = Invite codes9 invite_codes = Invite codes
10 bans = Bans10 bans = Bans
11 no_invite_codes = No invite codes11 no_invite_codes = No invite codes
12-no_bans = No bans
crates/client/lang/en/builder_overview.txtmodified+0 -2
@@ -1,9 +1,7 @@
1 users = Users1 users = Users
2 builders = Builders2 builders = Builders
3 communities = Communities3 communities = Communities
4-online = Online
5 in_voice = In voice4 in_voice = In voice
6 storage = Storage5 storage = Storage
7 active_users = Active users6 active_users = Active users
8-messages = Messages
9 server = Server7 server = Server
crates/client/lang/en/builder_users.txtmodified+0 -1
@@ -2,7 +2,6 @@ seen_never = never
2 seen_now = now2 seen_now = now
3 seen_minutes = {count}m ago3 seen_minutes = {count}m ago
4 seen_hours = {count}h ago4 seen_hours = {count}h ago
5-no_users = No users
6 create = Create5 create = Create
7 confirm = Confirm6 confirm = Confirm
8 revoke = Revoke7 revoke = Revoke
crates/client/lang/en/builder_voice.txtmodified+0 -1
@@ -2,7 +2,6 @@ no_rooms = No active voice rooms
2 join = Join2 join = Join
3 voice_on = Voice on3 voice_on = Voice on
4 voice_off = Voice off4 voice_off = Voice off
5-no_users = No users
6 muted = Muted5 muted = Muted
7 ghost = Ghost6 ghost = Ghost
8 unmute = Unmute7 unmute = Unmute
crates/client/lang/en/camera_view.txtmodified+0 -1
@@ -1,3 +1,2 @@
1 watch = Watch1 watch = Watch
2 screens = screens2 screens = screens
3-more = {count} more
crates/client/lang/en/chat.txtmodified+0 -2
@@ -47,8 +47,6 @@ grid = Grid
47 hide = Hide47 hide = Hide
48 stats = Connection stats48 stats = Connection stats
49 stats_hide = Hide connection stats49 stats_hide = Hide connection stats
50-online = Online
51-offline = Offline
52 new = New50 new = New
53 edited = (edited)51 edited = (edited)
54 calls = {count} calls52 calls = {count} calls
crates/client/lang/en/common.txtmodified+4 -0
@@ -18,3 +18,7 @@ year_stamp = %b %-d %Y, %H:%M
18 day = %b %-d18 day = %b %-d
19 day_year = %b %-d, %Y19 day_year = %b %-d, %Y
20 date = %b %-d %Y20 date = %b %-d %Y
21+more = {count} more
22+messages = Messages
23+no_users = No users
24+no_bans = No bans
crates/client/lang/en/community_card.txtmodified+0 -1
@@ -1,2 +1 @@
1 people = {members} members · {online} online1 people = {members} members · {online} online
2-more = {count} more
crates/client/lang/en/community_settings.txtmodified+0 -1
@@ -13,7 +13,6 @@ on = On
13 off = Off13 off = Off
14 view = View14 view = View
15 unban = Unban15 unban = Unban
16-no_bans = No bans
17 no_logs = No logs16 no_logs = No logs
18 someone = someone17 someone = someone
19 created = {actor} created the community18 created = {actor} created the community
crates/client/lang/en/message_actions.txtmodified+0 -1
@@ -10,4 +10,3 @@ confirm = Confirm
10 delete = Delete10 delete = Delete
11 send = Send11 send = Send
12 people = People12 people = People
13-messages = Messages
crates/client/lang/tr/builder.txtmodified+0 -1
@@ -1,7 +1,6 @@
1 overview = Genel Bakış1 overview = Genel Bakış
2 users = Kullanıcılar2 users = Kullanıcılar
3 communities = Topluluklar3 communities = Topluluklar
4-messages = Mesajlar
5 voice = Ses4 voice = Ses
6 storage = Depolama5 storage = Depolama
7 access = Erişim6 access = Erişim
crates/client/lang/tr/builder_access.txtmodified+0 -1
@@ -9,4 +9,3 @@ create = Oluştur
9 invite_codes = Davet kodları9 invite_codes = Davet kodları
10 bans = Yasaklar10 bans = Yasaklar
11 no_invite_codes = Davet kodu yok11 no_invite_codes = Davet kodu yok
12-no_bans = Yasak yok
crates/client/lang/tr/builder_overview.txtmodified+0 -2
@@ -1,9 +1,7 @@
1 users = Kullanıcılar1 users = Kullanıcılar
2 builders = Kurucular2 builders = Kurucular
3 communities = Topluluklar3 communities = Topluluklar
4-online = Çevrimiçi
5 in_voice = Seste4 in_voice = Seste
6 storage = Depolama5 storage = Depolama
7 active_users = Aktif kullanıcılar6 active_users = Aktif kullanıcılar
8-messages = Mesajlar
9 server = Sunucu7 server = Sunucu
crates/client/lang/tr/builder_users.txtmodified+0 -1
@@ -2,7 +2,6 @@ seen_never = hiç
2 seen_now = şimdi2 seen_now = şimdi
3 seen_minutes = {count} dk önce3 seen_minutes = {count} dk önce
4 seen_hours = {count} sa önce4 seen_hours = {count} sa önce
5-no_users = Kullanıcı yok
6 create = Oluştur5 create = Oluştur
7 confirm = Onayla6 confirm = Onayla
8 revoke = İptal et7 revoke = İptal et
crates/client/lang/tr/builder_voice.txtmodified+0 -1
@@ -2,7 +2,6 @@ no_rooms = Aktif ses odası yok
2 join = Katıl2 join = Katıl
3 voice_on = Ses açık3 voice_on = Ses açık
4 voice_off = Ses kapalı4 voice_off = Ses kapalı
5-no_users = Kullanıcı yok
6 muted = Susturuldu5 muted = Susturuldu
7 ghost = Hayalet6 ghost = Hayalet
8 unmute = Sesi aç7 unmute = Sesi aç
crates/client/lang/tr/camera_view.txtmodified+0 -1
@@ -1,3 +1,2 @@
1 watch = İzle1 watch = İzle
2 screens = ekran2 screens = ekran
3-more = {count} daha
crates/client/lang/tr/chat.txtmodified+0 -2
@@ -47,8 +47,6 @@ grid = Izgara
47 hide = Gizle47 hide = Gizle
48 stats = Bağlantı istatistikleri48 stats = Bağlantı istatistikleri
49 stats_hide = Bağlantı istatistiklerini gizle49 stats_hide = Bağlantı istatistiklerini gizle
50-online = Çevrimiçi
51-offline = Çevrimdışı
52 new = Yeni50 new = Yeni
53 edited = (düzenlendi)51 edited = (düzenlendi)
54 calls = {count} arama52 calls = {count} arama
crates/client/lang/tr/common.txtmodified+4 -0
@@ -18,3 +18,7 @@ year_stamp = %-d %b %Y, %H:%M
18 day = %-d %b18 day = %-d %b
19 day_year = %-d %b %Y19 day_year = %-d %b %Y
20 date = %-d %b %Y20 date = %-d %b %Y
21+more = {count} daha
22+messages = Mesajlar
23+no_users = Kullanıcı yok
24+no_bans = Yasak yok
crates/client/lang/tr/community_card.txtmodified+0 -1
@@ -1,2 +1 @@
1 people = {members} üye · {online} çevrimiçi1 people = {members} üye · {online} çevrimiçi
2-more = {count} kişi daha
crates/client/lang/tr/community_settings.txtmodified+0 -1
@@ -13,7 +13,6 @@ on = Açık
13 off = Kapalı13 off = Kapalı
14 view = Görüntüle14 view = Görüntüle
15 unban = Yasağı kaldır15 unban = Yasağı kaldır
16-no_bans = Yasak yok
17 no_logs = Kayıt yok16 no_logs = Kayıt yok
18 someone = birisi17 someone = birisi
19 created = {actor} topluluğu oluşturdu18 created = {actor} topluluğu oluşturdu
crates/client/lang/tr/message_actions.txtmodified+0 -1
@@ -10,4 +10,3 @@ confirm = Onayla
10 delete = Sil10 delete = Sil
11 send = Gönder11 send = Gönder
12 people = Kişiler12 people = Kişiler
13-messages = Mesajlar
crates/client/src/gui.rsmodified+9 -6
@@ -914,11 +914,9 @@ impl Yumush {
914 palette: Palette,914 palette: Palette,
915 ) -> Div {915 ) -> Div {
916 let icon = community_icon(palette, community, size, font, &self.chat.avatars);916 let icon = community_icon(palette, community, size, font, &self.chat.avatars);
917- match &community.kind {917+ match community.kind.peer() {
918- CommunityKind::Direct { peer } => {918+ Some(peer) => presence_avatar(icon, self.presence_of(peer.id), size, palette),
919- presence_avatar(icon, self.presence_of(peer.id), size, palette)919+ None => icon,
920- }
921- CommunityKind::Group | CommunityKind::Notes => icon,
922 }920 }
923 }921 }
924 922
@@ -933,6 +931,10 @@ impl Yumush {
933 .unwrap_or(Presence::Offline)931 .unwrap_or(Presence::Offline)
934 }932 }
935 933
934+ pub fn is_online(&self, user_id: Id) -> bool {
935+ self.presence_of(user_id) != Presence::Offline
936+ }
937+
936 pub fn request_avatar(&mut self, avatar_id: Id, cx: &mut Context<Self>) {938 pub fn request_avatar(&mut self, avatar_id: Id, cx: &mut Context<Self>) {
937 if self.chat.avatars.contains_key(&avatar_id)939 if self.chat.avatars.contains_key(&avatar_id)
938 || self.chat.avatar_requests.contains(&avatar_id)940 || self.chat.avatar_requests.contains(&avatar_id)
@@ -1115,7 +1117,8 @@ impl Yumush {
1115 self.chat1117 self.chat
1116 .communities()1118 .communities()
1117 .iter()1119 .iter()
1118- .any(|community| community.id == community_id && community.kind.is_direct())1120+ .find(|community| community.id == community_id)
1121+ .is_some_and(|community| community.kind.is_direct())
1119 }1122 }
1120 1123
1121 fn is_me(&self, user_id: Id) -> bool {1124 fn is_me(&self, user_id: Id) -> bool {
crates/client/src/gui/builder.rsmodified+3 -4
@@ -17,7 +17,7 @@ use std::{fmt::Display, future::Future, path::PathBuf};
17 17
18 use common::{18 use common::{
19 call::{ListUsers, SetGhost},19 call::{ListUsers, SetGhost},
20- model::{CommunityKind, Member, Role},20+ model::{Member, Role},
21 permission,21 permission,
22 };22 };
23 use gpui_kit::{23 use gpui_kit::{
@@ -90,7 +90,7 @@ impl BuilderTab {
90 Self::Overview => w.overview,90 Self::Overview => w.overview,
91 Self::Users => w.users,91 Self::Users => w.users,
92 Self::Communities => w.communities,92 Self::Communities => w.communities,
93- Self::Messages => w.messages,93+ Self::Messages => crate::lang::w().common.messages,
94 Self::Voice => w.voice,94 Self::Voice => w.voice,
95 Self::Storage => w.storage,95 Self::Storage => w.storage,
96 Self::Access => w.access,96 Self::Access => w.access,
@@ -377,8 +377,7 @@ impl Yumush {
377 .builder_communities377 .builder_communities
378 .iter()378 .iter()
379 .find(|summary| {379 .find(|summary| {
380- summary.community.kind == CommunityKind::Group380+ summary.community.kind.is_group() && summary.community.name.to_lowercase() == name
381- && summary.community.name.to_lowercase() == name
382 })381 })
383 .map(|summary| summary.community.id)382 .map(|summary| summary.community.id)
384 }383 }
crates/client/src/gui/builder/access.rsmodified+1 -7
@@ -279,13 +279,7 @@ impl Yumush {
279 palette,279 palette,
280 )280 )
281 .into_any_element(),281 .into_any_element(),
282- list_card(282+ list_card(ban_header, bans.collect(), w().common.no_bans, palette).into_any_element(),
283- ban_header,
284- bans.collect(),
285- w().builder_access.no_bans,
286- palette,
287- )
288- .into_any_element(),
289 ]283 ]
290 }284 }
291 }285 }
crates/client/src/gui/builder/overview.rsmodified+2 -2
@@ -192,7 +192,7 @@ impl Yumush {
192 w().builder_overview.communities,192 w().builder_overview.communities,
193 overview.communities.to_string(),193 overview.communities.to_string(),
194 ),194 ),
195- (w().builder_overview.online, overview.online.to_string()),195+ (w().common.presence_online, overview.online.to_string()),
196 (w().builder_overview.in_voice, overview.voice.to_string()),196 (w().builder_overview.in_voice, overview.voice.to_string()),
197 (197 (
198 w().builder_overview.storage,198 w().builder_overview.storage,
@@ -216,7 +216,7 @@ impl Yumush {
216 palette,216 palette,
217 ))217 ))
218 .child(bar_chart(218 .child(bar_chart(
219- w().builder_overview.messages,219+ w().common.messages,
220 stats,220 stats,
221 |stat| stat.messages,221 |stat| stat.messages,
222 messages,222 messages,
crates/client/src/gui/builder/ui.rsmodified+15 -2
@@ -1,5 +1,9 @@
1 use crate::gui::style::{radius, size, space, text};1 use crate::gui::style::{radius, size, space, text};
2-use crate::gui::{Palette, Tooltip as _, clickable, text, widget};2+use crate::gui::{
3+ Palette, Tooltip as _, clickable,
4+ parts::{self, Scale, Tone},
5+ text,
6+};
3 use crate::lang::w;7 use crate::lang::w;
4 use gpui_kit::{8 use gpui_kit::{
5 AnyElement, App, Div, FontWeight, Hsla, IntoElement, ParentElement, Stateful, Styled, Window,9 AnyElement, App, Div, FontWeight, Hsla, IntoElement, ParentElement, Stateful, Styled, Window,
@@ -47,7 +51,16 @@ pub(super) fn icon_button(
47 palette: Palette,51 palette: Palette,
48 action: impl Fn(&mut Window, &mut App) + 'static,52 action: impl Fn(&mut Window, &mut App) + 'static,
49 ) -> Stateful<Div> {53 ) -> Stateful<Div> {
50- widget::icon_button(id, palette, icon, tip, action).text_color(color)54+ parts::icon_button(
55+ id,
56+ icon,
57+ tip,
58+ Tone::Idle,
59+ Scale::Small,
60+ palette.tokens,
61+ action,
62+ )
63+ .text_color(color)
51 }64 }
52 65
53 pub(super) fn delete_icon_button(66 pub(super) fn delete_icon_button(
crates/client/src/gui/builder/users.rsmodified+1 -1
@@ -499,7 +499,7 @@ impl Yumush {
499 ));499 ));
500 500
501 let body = if rows.is_empty() {501 let body = if rows.is_empty() {
502- super::ui::empty(w().builder_users.no_users, palette)502+ super::ui::empty(w().common.no_users, palette)
503 } else {503 } else {
504 div().flex().flex_col().children(rows)504 div().flex().flex_col().children(rows)
505 };505 };
crates/client/src/gui/builder/voice.rsmodified+1 -1
@@ -167,7 +167,7 @@ impl Yumush {
167 167
168 card(palette)168 card(palette)
169 .child(card_header(&room.community, actions, palette))169 .child(card_header(&room.community, actions, palette))
170- .child(rows_body(rows, w().builder_voice.no_users, palette))170+ .child(rows_body(rows, w().common.no_users, palette))
171 }171 }
172 172
173 pub(super) fn voice_user_row(173 pub(super) fn voice_user_row(
crates/client/src/gui/call_bar.rsmodified+6 -1
@@ -8,7 +8,7 @@ use gpui_kit::{
8 8
9 use super::{9 use super::{
10 Tooltip as _,10 Tooltip as _,
11- parts::{Ink, Text, Tone, Voice, band, icon_button, thread, voice_line, words},11+ parts::{Ink, Scale, Text, Tone, Voice, band, icon_button, thread, voice_line, words},
12 style::{Tokens, size, space},12 style::{Tokens, size, space},
13 };13 };
14 use crate::lang::w;14 use crate::lang::w;
@@ -84,6 +84,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
84 w().call_bar.mute84 w().call_bar.mute
85 },85 },
86 alarm(bar.muted),86 alarm(bar.muted),
87+ Scale::Normal,
87 t,88 t,
88 run(&actions.mute),89 run(&actions.mute),
89 ))90 ))
@@ -101,6 +102,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
101 w().call_bar.deafen102 w().call_bar.deafen
102 },103 },
103 alarm(bar.deafened),104 alarm(bar.deafened),
105+ Scale::Normal,
104 t,106 t,
105 run(&actions.deafen),107 run(&actions.deafen),
106 ))108 ))
@@ -115,6 +117,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
115 w().call_bar.turn_on_camera117 w().call_bar.turn_on_camera
116 },118 },
117 tone(bar.camera),119 tone(bar.camera),
120+ Scale::Normal,
118 t,121 t,
119 run(&actions.camera),122 run(&actions.camera),
120 ))123 ))
@@ -128,6 +131,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
128 w().call_bar.share_screen131 w().call_bar.share_screen
129 },132 },
130 tone(bar.screen),133 tone(bar.screen),
134+ Scale::Normal,
131 t,135 t,
132 run(&actions.screen),136 run(&actions.screen),
133 ))137 ))
@@ -138,6 +142,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
138 IconName::PhoneOff,142 IconName::PhoneOff,
139 w().call_bar.leave_call,143 w().call_bar.leave_call,
140 Tone::Danger,144 Tone::Danger,
145+ Scale::Normal,
141 t,146 t,
142 run(&actions.leave),147 run(&actions.leave),
143 ));148 ));
crates/client/src/gui/camera_view.rsmodified+4 -7
@@ -311,13 +311,10 @@ impl Yumush {
311 )311 )
312 }))312 }))
313 })313 })
314- .chain((more > 0).then(|| {314+ .chain(
315- caption(315+ (more > 0)
316- w().camera_view.more(more),316+ .then(|| caption(w().common.more(more), voice_line(None, Voice::Quiet, t), t)),
317- voice_line(None, Voice::Quiet, t),317+ )
318- t,
319- )
320- }))
321 .collect()318 .collect()
322 }319 }
323 320
crates/client/src/gui/chat.rsmodified+15 -15
@@ -594,11 +594,11 @@ impl Chat {
594 }594 }
595 595
596 pub(super) fn unread_groups(&self) -> Unread {596 pub(super) fn unread_groups(&self) -> Unread {
597- self.unread_where(|kind| matches!(kind, CommunityKind::Group))597+ self.unread_where(|kind| kind.is_group())
598 }598 }
599 599
600 pub(super) fn unread_direct(&self) -> Unread {600 pub(super) fn unread_direct(&self) -> Unread {
601- self.unread_where(|kind| !matches!(kind, CommunityKind::Group))601+ self.unread_where(|kind| !kind.is_group())
602 }602 }
603 603
604 pub fn focus(&self, window: &mut Window, cx: &mut Context<Yumush>) {604 pub fn focus(&self, window: &mut Window, cx: &mut Context<Yumush>) {
@@ -1499,8 +1499,7 @@ impl Yumush {
1499 fn header(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {1499 fn header(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {
1500 let community = self.chat.selected_community();1500 let community = self.chat.selected_community();
1501 let name = community.map(community_name).unwrap_or_default();1501 let name = community.map(community_name).unwrap_or_default();
1502- let group =1502+ let group = community.is_some_and(|community| community.kind.is_group());
1503- community.is_some_and(|community| matches!(community.kind, CommunityKind::Group));
1504 let voice = self.voice_toggle(entity, palette);1503 let voice = self.voice_toggle(entity, palette);
1505 let peer = community.and_then(|community| match &community.kind {1504 let peer = community.and_then(|community| match &community.kind {
1506 CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)),1505 CommunityKind::Direct { peer } => Some(self.chat.author(peer.id).unwrap_or(peer)),
@@ -1576,7 +1575,7 @@ impl Yumush {
1576 ),1575 ),
1577 super::Zoom::new(1576 super::Zoom::new(
1578 super::picture_of(community, &self.chat.avatars),1577 super::picture_of(community, &self.chat.avatars),
1579- !matches!(community.kind, CommunityKind::Group),1578+ !community.kind.is_group(),
1580 name.to_string(),1579 name.to_string(),
1581 ),1580 ),
1582 )1581 )
@@ -2988,7 +2987,7 @@ fn members_column(
2988 let community_id = chat.selected_community_id?;2987 let community_id = chat.selected_community_id?;
2989 let group = chat2988 let group = chat
2990 .selected_community()2989 .selected_community()
2991- .is_some_and(|community| matches!(community.kind, CommunityKind::Group));2990+ .is_some_and(|community| community.kind.is_group());
2992 if !group {2991 if !group {
2993 return None;2992 return None;
2994 }2993 }
@@ -3122,15 +3121,11 @@ fn members_column(
3122 .flex()3121 .flex()
3123 .flex_col()3122 .flex_col()
3124 .child(3123 .child(
3125- div()3124+ super::parts::caption_head(format!("{title} · {total}"), palette.tokens)
3126- .px(px(space::SM))
3127 .pb(px(space::XS))3125 .pb(px(space::XS))
3128 .flex()3126 .flex()
3129 .items_center()3127 .items_center()
3130 .justify_between()3128 .justify_between()
3131- .text_size(text(text::CAPTION))
3132- .text_color(palette.muted)
3133- .child(format!("{title} · {total}"))
3134 .children(action),3129 .children(action),
3135 )3130 )
3136 .children(rows.into_iter().take(cap).map(row))3131 .children(rows.into_iter().take(cap).map(row))
@@ -3152,7 +3147,7 @@ fn members_column(
3152 .rounded(px(radius::MD))3147 .rounded(px(radius::MD))
3153 .text_size(text(text::CAPTION))3148 .text_size(text(text::CAPTION))
3154 .text_color(palette.muted)3149 .text_color(palette.muted)
3155- .child(w().community_card.more(more)),3150+ .child(w().common.more(more)),
3156 )3151 )
3157 })3152 })
3158 })3153 })
@@ -3217,9 +3212,14 @@ fn members_column(
3217 .border_color(palette.border)3212 .border_color(palette.border)
3218 .child(room_head(yumush, palette))3213 .child(room_head(yumush, palette))
3219 .children(call)3214 .children(call)
3220- .children(section(w().chat.online, online, usize::MAX, None))
3221 .children(section(3215 .children(section(
3222- w().chat.offline,3216+ w().common.presence_online,
3217+ online,
3218+ usize::MAX,
3219+ None,
3220+ ))
3221+ .children(section(
3222+ w().common.presence_offline,
3223 offline,3223 offline,
3224 if chat.offline_open {3224 if chat.offline_open {
3225 usize::MAX3225 usize::MAX
@@ -3238,7 +3238,7 @@ fn room_head(yumush: &Yumush, palette: Palette) -> Div {
3238 let online = chat3238 let online = chat
3239 .members3239 .members
3240 .iter()3240 .iter()
3241- .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline)3241+ .filter(|member| yumush.is_online(member.user.id))
3242 .count();3242 .count();
3243 3243
3244 div().px(px(space::SM)).child(super::parts::words(3244 div().px(px(space::SM)).child(super::parts::words(
crates/client/src/gui/community_card.rsmodified+2 -2
@@ -1,5 +1,5 @@
1 use common::{1 use common::{
2- model::{Community, Id, Presence},2+ model::{Community, Id},
3 permission,3 permission,
4 };4 };
5 use gpui_kit::{5 use gpui_kit::{
@@ -42,7 +42,7 @@ pub(super) fn community_popover(
42 .chat42 .chat
43 .members43 .members
44 .iter()44 .iter()
45- .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline)45+ .filter(|member| yumush.is_online(member.user.id))
46 .count();46 .count();
47 super::parts::popover(t)47 super::parts::popover(t)
48 .w(px(size::POPOVER))48 .w(px(size::POPOVER))
crates/client/src/gui/community_settings.rsmodified+1 -1
@@ -380,7 +380,7 @@ impl Yumush {
380 Yumush::set_ban_sort,380 Yumush::set_ban_sort,
381 ),381 ),
382 rows,382 rows,
383- w().community_settings.no_bans,383+ w().common.no_bans,
384 palette,384 palette,
385 ))385 ))
386 });386 });
crates/client/src/gui/composer.rsmodified+8 -3
@@ -1,6 +1,7 @@
1+use super::parts::{Scale, Tone, icon_button};
1 use super::style::{radius, size, space, stroke, text};2 use super::style::{radius, size, space, stroke, text};
2 use super::text;3 use super::text;
3-use super::widget::{compact_field, icon_button, panel, spawn_done};4+use super::widget::{compact_field, panel, spawn_done};
4 use crate::gui::glyph::Fill as _;5 use crate::gui::glyph::Fill as _;
5 use common::model::Id;6 use common::model::Id;
6 use std::time::{Duration, Instant};7 use std::time::{Duration, Instant};
@@ -184,9 +185,11 @@ fn cancel_button(entity: &Entity<Yumush>, palette: Palette) -> impl IntoElement
184 185
185 icon_button(186 icon_button(
186 "cancel_composer",187 "cancel_composer",
187- palette,
188 IconName::Close,188 IconName::Close,
189 w().composer.cancel,189 w().composer.cancel,
190+ Tone::Idle,
191+ Scale::Small,
192+ palette.tokens,
190 move |window, cx| {193 move |window, cx| {
191 entity.update(cx, |yumush, cx| yumush.cancel_composer(window, cx));194 entity.update(cx, |yumush, cx| yumush.cancel_composer(window, cx));
192 },195 },
@@ -708,9 +711,11 @@ pub fn plus_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i
708 (options.len() > MINIMUM_POLL_OPTIONS && !trailing_blank).then(|| {711 (options.len() > MINIMUM_POLL_OPTIONS && !trailing_blank).then(|| {
709 icon_button(712 icon_button(
710 format!("poll_remove_{index}"),713 format!("poll_remove_{index}"),
711- palette,
712 IconName::Close,714 IconName::Close,
713 w().composer.remove_option,715 w().composer.remove_option,
716+ Tone::Idle,
717+ Scale::Small,
718+ palette.tokens,
714 move |_, cx| {719 move |_, cx| {
715 remove.update(cx, |yumush, cx| {720 remove.update(cx, |yumush, cx| {
716 yumush.remove_poll_option(index, cx)721 yumush.remove_poll_option(index, cx)
crates/client/src/gui/gallery.rsmodified+4 -1
@@ -8,7 +8,7 @@ use gpui_kit::{
8 use super::call_bar::{self, CallActions, CallBar};8 use super::call_bar::{self, CallActions, CallBar};
9 use super::{9 use super::{
10 parts::{10 parts::{
11- Fill, Ink, Press, Text, Tone, Voice, band, button, caption, chevron, column, grow,11+ Fill, Ink, Press, Scale, Text, Tone, Voice, band, button, caption, chevron, column, grow,
12 icon_button, index_item, options, popover, row, section, spark, stack, strong, toggle,12 icon_button, index_item, options, popover, row, section, spark, stack, strong, toggle,
13 track, voice_line, words,13 track, voice_line, words,
14 },14 },
@@ -235,6 +235,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement {
235 IconName::Mic,235 IconName::Mic,
236 "Mute",236 "Mute",
237 Tone::Idle,237 Tone::Idle,
238+ Scale::Normal,
238 t,239 t,
239 |_, _| {},240 |_, _| {},
240 ))241 ))
@@ -244,6 +245,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement {
244 IconName::Camera,245 IconName::Camera,
245 "Camera",246 "Camera",
246 Tone::On,247 Tone::On,
248+ Scale::Normal,
247 t,249 t,
248 |_, _| {},250 |_, _| {},
249 ))251 ))
@@ -253,6 +255,7 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement {
253 IconName::PhoneOff,255 IconName::PhoneOff,
254 "Leave",256 "Leave",
255 Tone::Danger,257 Tone::Danger,
258+ Scale::Normal,
256 t,259 t,
257 |_, _| {},260 |_, _| {},
258 )),261 )),
crates/client/src/gui/jump.rsmodified+1 -4
@@ -145,10 +145,7 @@ impl Yumush {
145 .chat145 .chat
146 .communities146 .communities
147 .iter()147 .iter()
148- .filter_map(|community| match &community.kind {148+ .filter_map(|community| community.kind.peer().map(|peer| peer.id))
149- CommunityKind::Direct { peer } => Some(peer.id),
150- _ => None,
151- })
152 .collect();149 .collect();
153 let mut seen = std::collections::HashSet::new();150 let mut seen = std::collections::HashSet::new();
154 let people = self151 let people = self
crates/client/src/gui/media_view.rsmodified+9 -10
@@ -642,16 +642,15 @@ fn icon_button(
642 palette: Palette,642 palette: Palette,
643 on_click: impl Fn(&mut Window, &mut App) + 'static,643 on_click: impl Fn(&mut Window, &mut App) + 'static,
644 ) -> impl IntoElement {644 ) -> impl IntoElement {
645- clickable(id, palette, on_click)645+ super::parts::icon_button(
646- .tip(tip)646+ id,
647- .size(px(size::CONTROL))647+ icon,
648- .flex_shrink_0()648+ tip,
649- .flex()649+ super::parts::Tone::Idle,
650- .items_center()650+ super::parts::Scale::Normal,
651- .justify_center()651+ palette.tokens,
652- .rounded(px(radius::MD))652+ on_click,
653- .text_color(palette.text)653+ )
654- .child(Icon::new(icon).size(px(size::ICON)))
655 }654 }
656 655
657 fn file_view(656 fn file_view(
crates/client/src/gui/message_actions.rsmodified+12 -16
@@ -25,9 +25,11 @@ use super::{
25 chat::{Chat, ReportTarget},25 chat::{Chat, ReportTarget},
26 clickable,26 clickable,
27 composer::trigger_icon,27 composer::trigger_icon,
28- entity_action, millis_time, notify_error, primary_button, sidebar,28+ entity_action, millis_time, notify_error,
29+ parts::{Scale, Tone, icon_button},
30+ primary_button, sidebar,
29 style::{radius, size, space, text},31 style::{radius, size, space, text},
30- widget::{field, icon_button, panel, search_text, spawn_done},32+ widget::{field, panel, search_text, spawn_done},
31 };33 };
32 34
33 pub fn reactions(35 pub fn reactions(
@@ -324,11 +326,7 @@ pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) ->
324 .gap(px(space::XS))326 .gap(px(space::XS))
325 .child(sidebar::input_box(&input, palette))327 .child(sidebar::input_box(&input, palette))
326 .children((!people.is_empty()).then(|| {328 .children((!people.is_empty()).then(|| {
327- div()329+ super::parts::caption_head(w().message_actions.people, palette.tokens)
328- .px(px(space::SM))
329- .text_size(text(text::CAPTION))
330- .text_color(palette.muted)
331- .child(w().message_actions.people)
332 }))330 }))
333 .children(people.iter().map(|user| {331 .children(people.iter().map(|user| {
334 person_row(user, &entity, &popover, palette)332 person_row(user, &entity, &popover, palette)
@@ -346,13 +344,10 @@ pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) ->
346 .child(user.username.clone()),344 .child(user.username.clone()),
347 )345 )
348 }))346 }))
349- .children((!query.is_empty() && !hits.is_empty()).then(|| {347+ .children(
350- div()348+ (!query.is_empty() && !hits.is_empty())
351- .px(px(space::SM))349+ .then(|| super::parts::caption_head(w().common.messages, palette.tokens)),
352- .text_size(text(text::CAPTION))350+ )
353- .text_color(palette.muted)
354- .child(w().message_actions.messages)
355- }))
356 .children(hits.iter().map(|hit| {351 .children(hits.iter().map(|hit| {
357 jump_row("search_hit", hit, &entity, &popover, palette)352 jump_row("search_hit", hit, &entity, &popover, palette)
358 .children(hit.time.as_ref().map(|time| {353 .children(hit.time.as_ref().map(|time| {
@@ -648,12 +643,13 @@ fn action(
648 643
649 icon_button(644 icon_button(
650 format!("{name}_{message_id}"),645 format!("{name}_{message_id}"),
651- palette,
652 icon,646 icon,
653 tip,647 tip,
648+ Tone::Idle,
649+ Scale::Small,
650+ palette.tokens,
654 move |window, cx| {651 move |window, cx| {
655 entity.update(cx, |yumush, cx| run(yumush, message_id, window, cx));652 entity.update(cx, |yumush, cx| run(yumush, message_id, window, cx));
656 },653 },
657 )654 )
658- .size(px(size::CONTROL_SM))
659 }655 }
crates/client/src/gui/parts.rsmodified+17 -2
@@ -120,6 +120,10 @@ pub fn section(title: impl Into<SharedString>, t: Tokens) -> Div {
120 .pb(px(space::XS))120 .pb(px(space::XS))
121 }121 }
122 122
123+pub fn caption_head(content: impl Into<SharedString>, t: Tokens) -> Div {
124+ words(content, Text::Caption, Ink::Dim, t).px(px(space::SM))
125+}
126+
123 #[derive(Clone, Copy)]127 #[derive(Clone, Copy)]
124 pub enum Fill {128 pub enum Fill {
125 Part(f32),129 Part(f32),
@@ -279,11 +283,18 @@ pub enum Tone {
279 Danger,283 Danger,
280 }284 }
281 285
286+#[derive(Clone, Copy, PartialEq, Eq)]
287+pub enum Scale {
288+ Small,
289+ Normal,
290+}
291+
282 pub fn icon_button(292 pub fn icon_button(
283 id: impl Into<ElementId>,293 id: impl Into<ElementId>,
284 icon: IconName,294 icon: IconName,
285 tip: &'static str,295 tip: &'static str,
286 tone: Tone,296 tone: Tone,
297+ scale: Scale,
287 t: Tokens,298 t: Tokens,
288 on_click: impl Fn(&mut Window, &mut App) + 'static,299 on_click: impl Fn(&mut Window, &mut App) + 'static,
289 ) -> Stateful<Div> {300 ) -> Stateful<Div> {
@@ -292,12 +303,16 @@ pub fn icon_button(
292 Tone::On => (t.paper(), Some(t.press())),303 Tone::On => (t.paper(), Some(t.press())),
293 Tone::Danger => (t.bad(), None),304 Tone::Danger => (t.bad(), None),
294 };305 };
306+ let (control, glyph) = match scale {
307+ Scale::Small => (size::CONTROL_SM, size::ICON_SM),
308+ Scale::Normal => (size::CONTROL, size::ICON),
309+ };
295 let hov = t.hov();310 let hov = t.hov();
296 div()311 div()
297 .id(id)312 .id(id)
298 .tip(tip)313 .tip(tip)
299 .cursor_pointer()314 .cursor_pointer()
300- .size(px(size::CONTROL))315+ .size(px(control))
301 .flex_none()316 .flex_none()
302 .flex()317 .flex()
303 .items_center()318 .items_center()
@@ -307,7 +322,7 @@ pub fn icon_button(
307 .hover(move |style| style.bg(hov))322 .hover(move |style| style.bg(hov))
308 .text_color(ink)323 .text_color(ink)
309 .on_click(move |_, window, cx| on_click(window, cx))324 .on_click(move |_, window, cx| on_click(window, cx))
310- .child(Icon::new(icon).size(px(size::ICON)))325+ .child(Icon::new(icon).size(px(glyph)))
311 }326 }
312 327
313 pub fn chevron_face(open: bool, t: Tokens) -> Div {328 pub fn chevron_face(open: bool, t: Tokens) -> Div {
crates/client/src/gui/poll.rsmodified+22 -9
@@ -13,9 +13,10 @@ use super::{
13 Palette, Tooltip as _, Trigger, Yumush, avatar,13 Palette, Tooltip as _, Trigger, Yumush, avatar,
14 chat::Chat,14 chat::Chat,
15 clickable, hoverable,15 clickable, hoverable,
16+ parts::{Scale, Tone, icon_button},
16 style::{radius, size, space, text},17 style::{radius, size, space, text},
17 text,18 text,
18- widget::{icon_button, panel, spawn_done},19+ widget::{panel, spawn_done},
19 };20 };
20 21
21 pub fn voter_count(poll: &Poll) -> usize {22 pub fn voter_count(poll: &Poll) -> usize {
@@ -346,9 +347,11 @@ pub fn poll_card(
346 let close_entity = entity.clone();347 let close_entity = entity.clone();
347 icon_button(348 icon_button(
348 format!("poll_close_{close_id}"),349 format!("poll_close_{close_id}"),
349- palette,
350 IconName::CircleStop,350 IconName::CircleStop,
351 w().poll.end_poll,351 w().poll.end_poll,
352+ Tone::Idle,
353+ Scale::Small,
354+ palette.tokens,
352 move |window, cx| {355 move |window, cx| {
353 close_entity356 close_entity
354 .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx));357 .update(cx, |yumush, cx| yumush.close_poll(close_id, window, cx));
@@ -528,9 +531,11 @@ impl Yumush {
528 }))531 }))
529 .child(icon_button(532 .child(icon_button(
530 "poll_banner_jump",533 "poll_banner_jump",
531- palette,
532 IconName::ArrowUpRight,534 IconName::ArrowUpRight,
533 w().poll.jump_to_message,535 w().poll.jump_to_message,
536+ Tone::Idle,
537+ Scale::Small,
538+ palette.tokens,
534 move |window, cx| {539 move |window, cx| {
535 jump.update(cx, |yumush, cx| {540 jump.update(cx, |yumush, cx| {
536 yumush.go_to_message(message_id, window, cx)541 yumush.go_to_message(message_id, window, cx)
@@ -628,10 +633,18 @@ fn page_button(
628 palette: Palette,633 palette: Palette,
629 ) -> impl IntoElement {634 ) -> impl IntoElement {
630 let entity = entity.clone();635 let entity = entity.clone();
631- icon_button(id, palette, icon, tip, move |_, cx| {636+ icon_button(
632- entity.update(cx, |yumush, cx| {637+ id,
633- yumush.chat.poll_page = yumush.chat.poll_page.wrapping_add(step);638+ icon,
634- cx.notify();639+ tip,
635- });640+ Tone::Idle,
636- })641+ Scale::Small,
642+ palette.tokens,
643+ move |_, cx| {
644+ entity.update(cx, |yumush, cx| {
645+ yumush.chat.poll_page = yumush.chat.poll_page.wrapping_add(step);
646+ cx.notify();
647+ });
648+ },
649+ )
637 }650 }
crates/client/src/gui/profile.rsmodified+3 -1
@@ -26,7 +26,7 @@ use gpui_kit::{
26 26
27 use super::chat::{CardMenu, ReportTarget, View};27 use super::chat::{CardMenu, ReportTarget, View};
28 use super::message_actions::report_bar;28 use super::message_actions::report_bar;
29-use super::parts::{Ink, Text, Tone, Voice, band, icon_button, stack, voice_line, words};29+use super::parts::{Ink, Scale, Text, Tone, Voice, band, icon_button, stack, voice_line, words};
30 use super::social::Relation;30 use super::social::Relation;
31 use super::style::{radius, size, space, stroke, text};31 use super::style::{radius, size, space, stroke, text};
32 use super::widget::spawn_done;32 use super::widget::spawn_done;
@@ -273,6 +273,7 @@ impl Card {
273 IconName::Ellipsis,273 IconName::Ellipsis,
274 w().profile.more,274 w().profile.more,
275 Tone::Idle,275 Tone::Idle,
276+ Scale::Normal,
276 t,277 t,
277 card_menu_action(entity, CardMenu::More),278 card_menu_action(entity, CardMenu::More),
278 ))279 ))
@@ -481,6 +482,7 @@ impl Card {
481 },482 },
482 w().profile.mute,483 w().profile.mute,
483 Tone::Idle,484 Tone::Idle,
485+ Scale::Normal,
484 t,486 t,
485 entity_action(entity, move |yumush, window, cx| {487 entity_action(entity, move |yumush, window, cx| {
486 yumush.toggle_user_mute(user_id, window, cx)488 yumush.toggle_user_mute(user_id, window, cx)
crates/client/src/gui/share_view.rsmodified+13 -12
@@ -38,13 +38,13 @@ use super::{
38 clickable, entity_action,38 clickable, entity_action,
39 media_view::into_render_image,39 media_view::into_render_image,
40 notify_error,40 notify_error,
41- parts::{self, Tone, scrim},41+ parts::{self, Scale, Tone, icon_button, scrim},
42 settings_page::segmented,42 settings_page::segmented,
43 stream_stats::{stream_card, watch_stats},43 stream_stats::{stream_card, watch_stats},
44 style::{radius, size, space, text},44 style::{radius, size, space, text},
45 surface::Surface,45 surface::Surface,
46 text,46 text,
47- widget::{icon_button, spawn_warn},47+ widget::spawn_warn,
48 };48 };
49 use crate::{49 use crate::{
50 settings::{self, ShareAudio, ShareCodec, ShareSettings},50 settings::{self, ShareAudio, ShareCodec, ShareSettings},
@@ -820,6 +820,7 @@ impl Yumush {
820 IconName::ChartBar,820 IconName::ChartBar,
821 w().share_view.stream_stats,821 w().share_view.stream_stats,
822 if viewer.stats { Tone::On } else { Tone::Idle },822 if viewer.stats { Tone::On } else { Tone::Idle },
823+ Scale::Normal,
823 t,824 t,
824 move |_, cx| {825 move |_, cx| {
825 entity.update(cx, |yumush, cx| {826 entity.update(cx, |yumush, cx| {
@@ -865,7 +866,6 @@ impl Yumush {
865 let muted = self.settings.share.volume == 0.;866 let muted = self.settings.share.volume == 0.;
866 icon_button(867 icon_button(
867 format!("share_mute_{muted}"),868 format!("share_mute_{muted}"),
868- palette,
869 if muted {869 if muted {
870 IconName::VolumeX870 IconName::VolumeX
871 } else {871 } else {
@@ -876,6 +876,9 @@ impl Yumush {
876 } else {876 } else {
877 w().share_view.mute877 w().share_view.mute
878 },878 },
879+ Tone::Idle,
880+ Scale::Small,
881+ palette.tokens,
879 entity_action(entity, |yumush, window, cx| {882 entity_action(entity, |yumush, window, cx| {
880 yumush.toggle_share_mute(window, cx)883 yumush.toggle_share_mute(window, cx)
881 }),884 }),
@@ -888,16 +891,20 @@ impl Yumush {
888 }))891 }))
889 .child(icon_button(892 .child(icon_button(
890 format!("share_fullscreen_{}", viewer.fullscreen),893 format!("share_fullscreen_{}", viewer.fullscreen),
891- palette,
892 fullscreen_icon,894 fullscreen_icon,
893 fullscreen_tip,895 fullscreen_tip,
896+ Tone::Idle,
897+ Scale::Small,
898+ palette.tokens,
894 entity_action(entity, |yumush, _, cx| yumush.toggle_fullscreen(cx)),899 entity_action(entity, |yumush, _, cx| yumush.toggle_fullscreen(cx)),
895 ))900 ))
896 .child(icon_button(901 .child(icon_button(
897 "share_close".to_string(),902 "share_close".to_string(),
898- palette,
899 IconName::X,903 IconName::X,
900 w().share_view.close,904 w().share_view.close,
905+ Tone::Idle,
906+ Scale::Small,
907+ palette.tokens,
901 entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)),908 entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)),
902 )),909 )),
903 ),910 ),
@@ -1139,13 +1146,7 @@ fn group(label: &'static str, rows: Vec<impl IntoElement>, palette: Palette) ->
1139 .flex()1146 .flex()
1140 .flex_col()1147 .flex_col()
1141 .gap(px(space::XXS))1148 .gap(px(space::XXS))
1142- .child(1149+ .child(parts::caption_head(label, palette.tokens))
1143- div()
1144- .px(px(space::SM))
1145- .text_size(text(text::CAPTION))
1146- .text_color(palette.muted)
1147- .child(label),
1148- )
1149 .children(rows)1150 .children(rows)
1150 }1151 }
1151 1152
crates/client/src/gui/sidebar.rsmodified+12 -13
@@ -26,11 +26,12 @@ use super::{
26 Palette, Tooltip as _, Yumush, avatar,26 Palette, Tooltip as _, Yumush, avatar,
27 chat::{View, create_community},27 chat::{View, create_community},
28 clickable, community_icon, community_name, entity_action, hoverable, input_dialog,28 clickable, community_icon, community_name, entity_action, hoverable, input_dialog,
29+ parts::{Scale, Tone, icon_button},
29 presence_avatar,30 presence_avatar,
30 profile::profile_popover,31 profile::profile_popover,
31 social::Relation,32 social::Relation,
32 style::{radius, size, space, text},33 style::{radius, size, space, text},
33- widget::{bare_input, compact_frame, icon_button},34+ widget::{bare_input, compact_frame},
34 };35 };
35 36
36 const SLIDE: std::time::Duration = std::time::Duration::from_millis(320);37 const SLIDE: std::time::Duration = std::time::Duration::from_millis(320);
@@ -473,7 +474,7 @@ impl Yumush {
473 };474 };
474 let pins = self.rooms(entity, palette, |room| pinned.contains(&room.id));475 let pins = self.rooms(entity, palette, |room| pinned.contains(&room.id));
475 let groups = self.rooms(entity, palette, |room| {476 let groups = self.rooms(entity, palette, |room| {
476- matches!(room.kind, CommunityKind::Group) && !pinned.contains(&room.id)477+ room.kind.is_group() && !pinned.contains(&room.id)
477 });478 });
478 let people = std::iter::once(self.notes_row(entity, palette))479 let people = std::iter::once(self.notes_row(entity, palette))
479 .chain(self.rooms(entity, palette, |room| {480 .chain(self.rooms(entity, palette, |room| {
@@ -534,7 +535,7 @@ impl Yumush {
534 self.chat535 self.chat
535 .opened536 .opened
536 .as_ref()537 .as_ref()
537- .filter(|opened| matches!(opened.kind, CommunityKind::Group))538+ .filter(|opened| opened.kind.is_group())
538 .filter(|opened| !self.chat.joined(opened.id)),539 .filter(|opened| !self.chat.joined(opened.id)),
539 )540 )
540 .filter(|community| !matches!(community.kind, CommunityKind::Notes))541 .filter(|community| !matches!(community.kind, CommunityKind::Notes))
@@ -561,7 +562,7 @@ impl Yumush {
561 palette: Palette,562 palette: Palette,
562 ) -> AnyElement {563 ) -> AnyElement {
563 let active = self.chat.is_selected(community.id);564 let active = self.chat.is_selected(community.id);
564- let group = matches!(community.kind, CommunityKind::Group);565+ let group = community.kind.is_group();
565 let can_leave = group && (!active || permission::can_leave(self.actor_rank()));566 let can_leave = group && (!active || permission::can_leave(self.actor_rank()));
566 let muted = self.chat.muted.contains(&community.id);567 let muted = self.chat.muted.contains(&community.id);
567 let unread = self.chat.unread.get(&community.id);568 let unread = self.chat.unread.get(&community.id);
@@ -889,9 +890,11 @@ impl Yumush {
889 div().child(890 div().child(
890 icon_button(891 icon_button(
891 "builder_button".to_string(),892 "builder_button".to_string(),
892- palette,
893 IconName::Ghost,893 IconName::Ghost,
894 w().sidebar.ghost_on,894 w().sidebar.ghost_on,
895+ Tone::Idle,
896+ Scale::Small,
897+ palette.tokens,
895 entity_action(entity, |yumush, window, cx| {898 entity_action(entity, |yumush, window, cx| {
896 yumush.show_view(View::Builder, window, cx)899 yumush.show_view(View::Builder, window, cx)
897 }),900 }),
@@ -1082,13 +1085,7 @@ fn group(title: &'static str, palette: Palette, rows: Vec<AnyElement>) -> Option
1082 .flex()1085 .flex()
1083 .flex_col()1086 .flex_col()
1084 .gap(px(space::XXS))1087 .gap(px(space::XXS))
1085- .child(1088+ .child(super::parts::caption_head(title, palette.tokens))
1086- div()
1087- .px(px(space::SM))
1088- .text_size(text(text::CAPTION))
1089- .text_color(palette.muted)
1090- .child(title),
1091- )
1092 .children(rows)1089 .children(rows)
1093 })1090 })
1094 }1091 }
@@ -1164,9 +1161,11 @@ fn row_button(
1164 ) -> AnyElement {1161 ) -> AnyElement {
1165 icon_button(1162 icon_button(
1166 format!("{key}_{id}"),1163 format!("{key}_{id}"),
1167- palette,
1168 icon,1164 icon,
1169 tip,1165 tip,
1166+ Tone::Idle,
1167+ Scale::Small,
1168+ palette.tokens,
1170 entity_action(entity, move |yumush, window, cx| {1169 entity_action(entity, move |yumush, window, cx| {
1171 run(yumush, id, window, cx)1170 run(yumush, id, window, cx)
1172 }),1171 }),
crates/client/src/gui/social.rsmodified+2 -5
@@ -8,7 +8,7 @@ use common::{
8 ListFriends, ListInvitations, ListMembers, ListPresences, OpenDirect, OpenNotes,8 ListFriends, ListInvitations, ListMembers, ListPresences, OpenDirect, OpenNotes,
9 RemoveFriend,9 RemoveFriend,
10 },10 },
11- model::{Community, CommunityKind, Rank, User},11+ model::{Community, Rank, User},
12 validate::validate_username,12 validate::validate_username,
13 };13 };
14 use gpui_kit::{14 use gpui_kit::{
@@ -107,10 +107,7 @@ impl Yumush {
107 .chain(107 .chain(
108 chat.communities108 chat.communities
109 .iter()109 .iter()
110- .filter_map(|community| match &community.kind {110+ .filter_map(|community| community.kind.peer()),
111- CommunityKind::Direct { peer } => Some(peer),
112- CommunityKind::Group | CommunityKind::Notes => None,
113- }),
114 );111 );
115 let avatar_ids: Vec<Id> = users112 let avatar_ids: Vec<Id> = users
116 .filter_map(|user| user.avatar_id)113 .filter_map(|user| user.avatar_id)
crates/client/src/gui/widget.rsmodified+3 -24
@@ -1,37 +1,16 @@
1 use std::{fmt::Display, future::Future};1 use std::{fmt::Display, future::Future};
2 2
3 use gpui_kit::{3 use gpui_kit::{
4- App, AsyncWindowContext, Context, Div, ElementId, Entity, ParentElement, Stateful, Styled,4+ App, AsyncWindowContext, Context, Div, Entity, ParentElement, Styled, WeakEntity, Window,
5- WeakEntity, Window,5+ component::{input::Input, input::InputState},
6- assets::IconName,
7- component::{Icon, input::Input, input::InputState},
8 div, px,6 div, px,
9 };7 };
10 8
11 use super::{9 use super::{
12- Palette, Tooltip as _, Yumush, clickable, notify_error,10+ Palette, Yumush, notify_error,
13 style::{size, space},11 style::{size, space},
14 };12 };
15 13
16-pub(super) fn icon_button(
17- id: impl Into<ElementId>,
18- palette: Palette,
19- icon: IconName,
20- tip: &'static str,
21- on_click: impl Fn(&mut Window, &mut App) + 'static,
22-) -> Stateful<Div> {
23- clickable(id, palette, on_click)
24- .tip(tip)
25- .size(px(size::CONTROL_SM))
26- .flex_shrink_0()
27- .flex()
28- .items_center()
29- .justify_center()
30- .rounded_full()
31- .text_color(palette.muted)
32- .child(Icon::new(icon).size(px(size::ICON_SM)))
33-}
34-
35 pub(super) fn panel(palette: Palette) -> Div {14 pub(super) fn panel(palette: Palette) -> Div {
36 super::parts::surface(palette.tokens)15 super::parts::surface(palette.tokens)
37 }16 }
crates/common/src/model.rsmodified+11 -0
@@ -131,9 +131,20 @@ pub enum CommunityKind {
131 }131 }
132 132
133 impl CommunityKind {133 impl CommunityKind {
134+ pub fn is_group(&self) -> bool {
135+ matches!(self, Self::Group)
136+ }
137+
134 pub fn is_direct(&self) -> bool {138 pub fn is_direct(&self) -> bool {
135 matches!(self, Self::Direct { .. })139 matches!(self, Self::Direct { .. })
136 }140 }
141+
142+ pub fn peer(&self) -> Option<&User> {
143+ match self {
144+ Self::Direct { peer } => Some(peer),
145+ Self::Group | Self::Notes => None,
146+ }
147+ }
137 }148 }
138 149
139 #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)]150 #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)]