forge
Explore
Log in

Don't you dare go Hollow

Room view deduplicated: title ⌄ opens one margin (room actions, voice lines in call), one search for people and messages, call pill is a count, format joins + menu, one mic/send slot

Browse files at this commit

c44c5fcd6840a1b1a10818de75105af90bbff407Ahmet Kaan GümüşParent: b1995a0
  • refactor
    • room view deduplicated: title ⌄ opens one margin (room actions, voice lines in call), one search for people and messages, call pill is a count, format joins + menu, one mic/send slot
Show full message
♻️ refactor: room view deduplicated: title ⌄ opens one margin (room actions, voice lines in call), one search for people and messages, call pill is a count, format joins + menu, one mic/send slot
crates/client/lang/en/chat.txtmodified+0 -1
@@ -1,7 +1,6 @@
1 message = Message1 message = Message
2 find = Find2 find = Find
3 find_user = Find user3 find_user = Find user
4-search_messages = Search messages
5 search = Search...4 search = Search...
6 new_password = New password...5 new_password = New password...
7 password = Password...6 password = Password...
crates/client/lang/en/composer.txtmodified+1 -0
@@ -10,6 +10,7 @@ option = Option
10 remove_option = Remove option10 remove_option = Remove option
11 file = File11 file = File
12 poll = Poll12 poll = Poll
13+format = Format
13 hour = 1h14 hour = 1h
14 day = 1d15 day = 1d
15 week = 1w16 week = 1w
crates/client/lang/en/message_actions.txtmodified+2 -0
@@ -9,3 +9,5 @@ report = Report
9 confirm = Confirm9 confirm = Confirm
10 delete = Delete10 delete = Delete
11 send = Send11 send = Send
12+people = People
13+messages = Messages
crates/client/lang/tr/chat.txtmodified+0 -1
@@ -1,7 +1,6 @@
1 message = Mesaj1 message = Mesaj
2 find = Bul2 find = Bul
3 find_user = Kullanıcı bul3 find_user = Kullanıcı bul
4-search_messages = Mesajlarda ara
5 search = Ara...4 search = Ara...
6 new_password = Yeni şifre...5 new_password = Yeni şifre...
7 password = Şifre...6 password = Şifre...
crates/client/lang/tr/composer.txtmodified+1 -0
@@ -10,6 +10,7 @@ option = Seçenek
10 remove_option = Seçeneği kaldır10 remove_option = Seçeneği kaldır
11 file = Dosya11 file = Dosya
12 poll = Anket12 poll = Anket
13+format = Biçim
13 hour = 1 sa14 hour = 1 sa
14 day = 1 gün15 day = 1 gün
15 week = 1 hafta16 week = 1 hafta
crates/client/lang/tr/message_actions.txtmodified+2 -0
@@ -9,3 +9,5 @@ report = Bildir
9 confirm = Onayla9 confirm = Onayla
10 delete = Sil10 delete = Sil
11 send = Gönder11 send = Gönder
12+people = Kişiler
13+messages = Mesajlar
crates/client/src/gui.rsmodified+0 -1
@@ -43,7 +43,6 @@ mod builder;
43 mod call_bar;43 mod call_bar;
44 mod camera_view;44 mod camera_view;
45 mod chat;45 mod chat;
46-mod community_card;
47 mod community_settings;46 mod community_settings;
48 mod composer;47 mod composer;
49 mod dock;48 mod dock;
crates/client/src/gui/chat.rsmodified+150 -92
@@ -3,6 +3,7 @@ use super::text;
3 use crate::gui::CLOCK;3 use crate::gui::CLOCK;
4 use crate::gui::glyph::Fill as _;4 use crate::gui::glyph::Fill as _;
5 use crate::lang::w;5 use crate::lang::w;
6+use crate::marks::Mark;
6 use std::{7 use std::{
7 collections::{BTreeMap, HashMap, HashSet, VecDeque},8 collections::{BTreeMap, HashMap, HashSet, VecDeque},
8 sync::Arc,9 sync::Arc,
@@ -106,7 +107,6 @@ enum History {
106 End,107 End,
107 }108 }
108 109
109-const FACES: usize = 3;
110 110
111 impl History {111 impl History {
112 fn of_page(length: usize) -> Self {112 fn of_page(length: usize) -> Self {
@@ -150,7 +150,6 @@ pub struct Chat {
150 pub(super) search_input: Entity<InputState>,150 pub(super) search_input: Entity<InputState>,
151 pub(super) friends_open: bool,151 pub(super) friends_open: bool,
152 pub(super) open_calls: HashSet<Id>,152 pub(super) open_calls: HashSet<Id>,
153- pub(super) member_input: Entity<InputState>,
154 pub(super) community_search: Entity<InputState>,153 pub(super) community_search: Entity<InputState>,
155 pub(super) community_hits: Vec<MessageHit>,154 pub(super) community_hits: Vec<MessageHit>,
156 pub(super) found: Option<User>,155 pub(super) found: Option<User>,
@@ -347,14 +346,6 @@ impl Chat {
347 )346 )
348 .detach();347 .detach();
349 348
350- let member_input = new_input(w().chat.find, window, cx);
351- cx.subscribe_in(&member_input, window, |_, _, event, _, cx| {
352- if matches!(event, InputEvent::Change) {
353- cx.notify();
354- }
355- })
356- .detach();
357-
358 let search_input = new_input(w().chat.find_user, window, cx);349 let search_input = new_input(w().chat.find_user, window, cx);
359 cx.subscribe_in(350 cx.subscribe_in(
360 &search_input,351 &search_input,
@@ -367,7 +358,7 @@ impl Chat {
367 )358 )
368 .detach();359 .detach();
369 360
370- let community_search = new_input(w().chat.search_messages, window, cx);361+ let community_search = new_input(w().chat.find, window, cx);
371 cx.subscribe_in(&community_search, window, |this, _, event, window, cx| {362 cx.subscribe_in(&community_search, window, |this, _, event, window, cx| {
372 if matches!(event, InputEvent::PressEnter { .. }) {363 if matches!(event, InputEvent::PressEnter { .. }) {
373 this.search_community(window, cx);364 this.search_community(window, cx);
@@ -440,7 +431,6 @@ impl Chat {
440 search_input,431 search_input,
441 friends_open: false,432 friends_open: false,
442 open_calls: HashSet::new(),433 open_calls: HashSet::new(),
443- member_input,
444 community_search,434 community_search,
445 community_hits: vec![],435 community_hits: vec![],
446 found: None,436 found: None,
@@ -1445,7 +1435,7 @@ impl Yumush {
1445 },1435 },
1446 }1436 }
1447 }))1437 }))
1448- .children(members_column(entity, self, themed, cx)),1438+ .children(members_column(entity, self, themed)),
1449 ),1439 ),
1450 None => panel.child(empty_state(palette)),1440 None => panel.child(empty_state(palette)),
1451 },1441 },
@@ -1557,22 +1547,30 @@ impl Yumush {
1557 .child(title),1547 .child(title),
1558 )1548 )
1559 .into_any_element(),1549 .into_any_element(),
1560- (None, Some(room)) => super::community_card::community_popover(1550+ (None, Some(room)) => clickable(
1551+ "room_title",
1552+ palette,
1553+ entity_action(entity, |yumush, _, cx| {
1554+ yumush.chat.members_open = !yumush.chat.members_open;
1555+ cx.notify();
1556+ }),
1557+ )
1558+ .tip(w().chat.people)
1559+ .flex()
1560+ .items_center()
1561+ .gap(px(space::SM))
1562+ .child(super::community_icon(
1563+ palette,
1561 room,1564 room,
1562- entity,1565+ px(size::AVATAR),
1563- div()1566+ super::text(super::style::text::CAPTION),
1564- .cursor_pointer()1567+ &self.chat.avatars,
1565- .flex()1568+ ))
1566- .items_center()1569+ .child(title)
1567- .gap(px(space::SM))1570+ .child(
1568- .child(super::community_icon(1571+ Icon::new(IconName::ChevronDown)
1569- palette,1572+ .size(px(size::ICON_SM))
1570- room,1573+ .text_color(palette.tokens.faint()),
1571- px(size::AVATAR),
1572- super::text(super::style::text::CAPTION),
1573- &self.chat.avatars,
1574- ))
1575- .child(title),
1576 )1574 )
1577 .into_any_element(),1575 .into_any_element(),
1578 _ => div()1576 _ => div()
@@ -1616,21 +1614,6 @@ impl Yumush {
1616 (community.is_some() && !self.chat.pins.is_empty())1614 (community.is_some() && !self.chat.pins.is_empty())
1617 .then(|| message_actions::pins_popover(&self.chat, entity, palette)),1615 .then(|| message_actions::pins_popover(&self.chat, entity, palette)),
1618 )1616 )
1619- .children(group.then(|| {
1620- icon_button(
1621- "members_button",
1622- palette,
1623- IconName::Users,
1624- w().chat.people,
1625- entity_action(entity, |yumush, _, cx| {
1626- yumush.chat.members_open = !yumush.chat.members_open;
1627- cx.notify();
1628- }),
1629- )
1630- .when(self.chat.members_open, |button| {
1631- button.text_color(palette.text)
1632- })
1633- }))
1634 .children(self.calling_hint(palette))1617 .children(self.calling_hint(palette))
1635 .children(voice.is_some().then(|| {1618 .children(voice.is_some().then(|| {
1636 div()1619 div()
@@ -1881,7 +1864,8 @@ impl Yumush {
1881 .into_any_element();1864 .into_any_element();
1882 }1865 }
1883 1866
1884- let has_text = self.chat.message_input.read(cx).text().len() > 0;1867+ let ready = self.chat.message_input.read(cx).text().len() > 0
1868+ || !self.chat.media.pending.is_empty();
1885 1869
1886 composer::format_actions(1870 composer::format_actions(
1887 &self.chat.message_input,1871 &self.chat.message_input,
@@ -1910,7 +1894,6 @@ impl Yumush {
1910 .items_center()1894 .items_center()
1911 .gap(px(space::SM))1895 .gap(px(space::SM))
1912 .child(composer::plus_popover(&self.chat, &entity, palette))1896 .child(composer::plus_popover(&self.chat, &entity, palette))
1913- .child(composer::format_popover(palette))
1914 .child(super::glyph::picker_button(1897 .child(super::glyph::picker_button(
1915 "composer_emoji",1898 "composer_emoji",
1916 &entity,1899 &entity,
@@ -1938,23 +1921,25 @@ impl Yumush {
1938 .flex_1()1921 .flex_1()
1939 .min_w_0(),1922 .min_w_0(),
1940 )1923 )
1941- .child(voice_note::mic_button(&entity, palette))1924+ .when(!ready, |this| {
1942- .child(1925+ this.child(voice_note::mic_button(&entity, palette))
1943- clickable("send_button", palette, move |window, cx| {1926+ })
1944- entity.update(cx, |yumush, cx| yumush.submit_composer(&input, window, cx))1927+ .when(ready, |this| {
1945- })1928+ this.child(
1946- .tip(w().chat.send)1929+ clickable("send_button", palette, move |window, cx| {
1947- .size(px(size::CONTROL_SM))1930+ entity.update(cx, |yumush, cx| {
1948- .flex()1931+ yumush.submit_composer(&input, window, cx)
1949- .items_center()1932+ })
1950- .justify_center()1933+ })
1951- .text_color(if has_text {1934+ .tip(w().chat.send)
1952- palette.text1935+ .size(px(size::CONTROL_SM))
1953- } else {1936+ .flex()
1954- palette.muted1937+ .items_center()
1955- })1938+ .justify_center()
1956- .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))),1939+ .text_color(palette.text)
1957- ),1940+ .child(Icon::new(IconName::ArrowUp).size(px(size::ICON_SM))),
1941+ )
1942+ }),
1958 )1943 )
1959 .into_any_element()1944 .into_any_element()
1960 }1945 }
@@ -2777,7 +2762,6 @@ impl Yumush {
2777 .first()2762 .first()
2778 .map(|user| user.id)2763 .map(|user| user.id)
2779 .filter(|id| self.chat.waves.speaking.contains(id));2764 .filter(|id| self.chat.waves.speaking.contains(id));
2780- let more = users.len().saturating_sub(FACES);
2781 let (icon, label) = match (direct, in_voice) {2765 let (icon, label) = match (direct, in_voice) {
2782 (true, false) => (IconName::Phone, w().chat.call),2766 (true, false) => (IconName::Phone, w().chat.call),
2783 (true, true) => (IconName::PhoneOff, w().chat.hang_up),2767 (true, true) => (IconName::PhoneOff, w().chat.hang_up),
@@ -2825,24 +2809,12 @@ impl Yumush {
2825 .h(px(space::LG))2809 .h(px(space::LG))
2826 .child(super::parts::voice_line(bands, voice, t)),2810 .child(super::parts::voice_line(bands, voice, t)),
2827 )2811 )
2828- .children(users.iter().take(FACES).enumerate().map(|(index, user)| {2812+ .child(super::parts::words(
2829- avatar(2813+ users.len().to_string(),
2830- palette,2814+ super::parts::Text::Ui,
2831- user,2815+ super::parts::Ink::Paper,
2832- px(size::AVATAR),2816+ t,
2833- super::text(super::style::text::CAPTION),2817+ ))
2834- &self.chat.avatars,
2835- )
2836- .when(index > 0, |avatar| avatar.ml(px(-space::XS)))
2837- }))
2838- .when(more > 0, |this| {
2839- this.child(super::parts::words(
2840- format!("+{more}"),
2841- super::parts::Text::Caption,
2842- super::parts::Ink::Dim,
2843- t,
2844- ))
2845- })
2846 })2818 })
2847 .child(super::parts::words(label, super::parts::Text::Ui, ink, t)),2819 .child(super::parts::words(label, super::parts::Text::Ui, ink, t)),
2848 )2820 )
@@ -3048,7 +3020,6 @@ fn members_column(
3048 entity: &Entity<Yumush>,3020 entity: &Entity<Yumush>,
3049 yumush: &Yumush,3021 yumush: &Yumush,
3050 palette: Palette,3022 palette: Palette,
3051- cx: &App,
3052 ) -> Option<gpui_kit::Stateful<Div>> {3023 ) -> Option<gpui_kit::Stateful<Div>> {
3053 let chat = &yumush.chat;3024 let chat = &yumush.chat;
3054 let community_id = chat.selected_community_id?;3025 let community_id = chat.selected_community_id?;
@@ -3059,11 +3030,9 @@ fn members_column(
3059 return None;3030 return None;
3060 }3031 }
3061 let voice = chat.voice_ids(community_id);3032 let voice = chat.voice_ids(community_id);
3062- let query = search_text(&chat.member_input, cx);
3063 let members: Vec<MemberRow> = chat3033 let members: Vec<MemberRow> = chat
3064 .members3034 .members
3065 .iter()3035 .iter()
3066- .filter(|member| member.user.username.to_lowercase().contains(&query))
3067 .map(|member| MemberRow {3036 .map(|member| MemberRow {
3068 user: member.user.clone(),3037 user: member.user.clone(),
3069 rank: chat.rank_of(&member.user),3038 rank: chat.rank_of(&member.user),
@@ -3114,18 +3083,13 @@ fn members_column(
3114 .gap(px(space::SM))3083 .gap(px(space::SM))
3115 .child(user.username.clone())3084 .child(user.username.clone())
3116 .children(rank_tag(*rank, palette))3085 .children(rank_tag(*rank, palette))
3117- .children(in_voice.then(|| {
3118- Icon::new(IconName::Headphones)
3119- .size(px(size::ICON_SM))
3120- .text_color(palette.muted)
3121- }))
3122 .children(muted.then(|| {3086 .children(muted.then(|| {
3123 Icon::new(IconName::MicOff)3087 Icon::new(IconName::MicOff)
3124 .size(px(size::ICON_SM))3088 .size(px(size::ICON_SM))
3125 .text_color(palette.danger)3089 .text_color(palette.danger)
3126 })),3090 })),
3127 )3091 )
3128- .children((!user.status.is_empty()).then(|| {3092+ .children((!user.status.is_empty() && !in_voice).then(|| {
3129 div()3093 div()
3130 .text_size(text(text::CAPTION))3094 .text_size(text(text::CAPTION))
3131 .text_color(palette.muted)3095 .text_color(palette.muted)
@@ -3135,7 +3099,23 @@ fn members_column(
3135 super::text(super::style::text::CAPTION),3099 super::text(super::style::text::CAPTION),
3136 ))3100 ))
3137 })),3101 })),
3138- ),3102+ )
3103+ .children(in_voice.then(|| {
3104+ let speaking = chat.waves.speaking.contains(&user.id);
3105+ div()
3106+ .w(px(size::CONTROL * 1.5))
3107+ .h(px(space::LG))
3108+ .flex_none()
3109+ .child(super::parts::voice_line(
3110+ chat.waves.voice(user.id),
3111+ if speaking {
3112+ super::parts::Voice::Live(palette.tokens.person(user.id))
3113+ } else {
3114+ super::parts::Voice::Quiet
3115+ },
3116+ palette.tokens,
3117+ ))
3118+ })),
3139 palette,3119 palette,
3140 ),3120 ),
3141 )3121 )
@@ -3180,13 +3160,91 @@ fn members_column(
3180 .gap(px(space::LG))3160 .gap(px(space::LG))
3181 .border_l_1()3161 .border_l_1()
3182 .border_color(palette.border)3162 .border_color(palette.border)
3183- .child(super::sidebar::input_box(&chat.member_input, palette))3163+ .child(room_head(yumush, community_id, &entity, palette))
3184 .children(section(w().chat.in_call, in_call))3164 .children(section(w().chat.in_call, in_call))
3185 .children(section(w().chat.online, online))3165 .children(section(w().chat.online, online))
3186 .children(section(w().chat.offline, offline)),3166 .children(section(w().chat.offline, offline)),
3187 )3167 )
3188 }3168 }
3189 3169
3170+fn room_head(yumush: &Yumush, id: Id, entity: &Entity<Yumush>, palette: Palette) -> Div {
3171+ let chat = &yumush.chat;
3172+ let online = chat
3173+ .members
3174+ .iter()
3175+ .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline)
3176+ .count();
3177+ let pinned = chat.pinned.contains(&id);
3178+ let muted = chat.muted.contains(&id);
3179+ let words = &w().sidebar;
3180+ let action = |key: &'static str,
3181+ icon: IconName,
3182+ tip: &'static str,
3183+ run: fn(&mut Yumush, Id, &mut Window, &mut Context<Yumush>)| {
3184+ icon_button(
3185+ key,
3186+ palette,
3187+ icon,
3188+ tip,
3189+ entity_action(entity, move |yumush, window, cx| run(yumush, id, window, cx)),
3190+ )
3191+ };
3192+
3193+ div()
3194+ .px(px(space::SM))
3195+ .flex()
3196+ .flex_col()
3197+ .gap(px(space::XS))
3198+ .child(super::parts::words(
3199+ w().community_card.people(chat.members.len(), online),
3200+ super::parts::Text::Caption,
3201+ super::parts::Ink::Dim,
3202+ palette.tokens,
3203+ ))
3204+ .child(
3205+ div()
3206+ .ml(px(-space::SM))
3207+ .flex()
3208+ .items_center()
3209+ .child(action(
3210+ "room_invite",
3211+ IconName::UserPlus,
3212+ words.invite,
3213+ |yumush, id, window, cx| yumush.open_invite(id, window, cx),
3214+ ))
3215+ .child(action(
3216+ "room_mute",
3217+ if muted { IconName::BellOff } else { IconName::Bell },
3218+ if muted { words.unmute } else { words.mute },
3219+ |yumush, id, _, cx| yumush.toggle_mark(Mark::Mute, id, cx),
3220+ ))
3221+ .child(
3222+ action(
3223+ "room_pin",
3224+ IconName::Pin,
3225+ if pinned { words.unpin } else { words.pin },
3226+ |yumush, id, _, cx| yumush.toggle_mark(Mark::Pin, id, cx),
3227+ )
3228+ .when(pinned, |button| button.text_color(palette.text)),
3229+ )
3230+ .child(action(
3231+ "room_settings",
3232+ IconName::Settings,
3233+ words.settings,
3234+ |yumush, id, window, cx| yumush.open_community_settings(id, window, cx),
3235+ ))
3236+ .children(permission::can_leave(yumush.actor_rank()).then(|| {
3237+ action(
3238+ "room_leave",
3239+ IconName::LogOut,
3240+ words.leave,
3241+ |yumush, id, window, cx| yumush.leave_community(id, window, cx),
3242+ )
3243+ .text_color(palette.danger)
3244+ })),
3245+ )
3246+}
3247+
3190 fn accent_bar(palette: Palette) -> Div {3248 fn accent_bar(palette: Palette) -> Div {
3191 div()3249 div()
3192 .flex()3250 .flex()
crates/client/src/gui/community_card.rsdeleted+0 -157
@@ -1,157 +0,0 @@
1-use common::{
2- model::{Community, Id, Presence},
3- permission,
4-};
5-use gpui_kit::{
6- Anchor, Context, Entity, FontWeight, Hsla, IntoElement, ParentElement, Styled, Window,
7- assets::IconName, component::popover::Popover, div, px,
8-};
9-
10-use super::parts::{Ink, Text, band, stack, words};
11-use super::profile::{menu_icon, menu_row, yumush_action};
12-use super::style::{size, space, stroke, text};
13-use super::{Trigger, Yumush, text};
14-use crate::lang::w;
15-use crate::marks::Mark;
16-
17-pub(super) fn community_popover(
18- community: &Community,
19- entity: &Entity<Yumush>,
20- trigger: impl IntoElement,
21-) -> Popover {
22- let community = community.clone();
23- let entity = entity.clone();
24-
25- Popover::new("community_card")
26- .anchor(Anchor::TopLeft)
27- .appearance(false)
28- .trigger(Trigger::new(trigger))
29- .content(move |_, _, cx| {
30- let popover = cx.entity();
31- let yumush = entity.read(cx);
32- let palette = super::palette(cx);
33- let t = palette.tokens;
34- let id = community.id;
35- let name = super::community_name(&community).to_string();
36- let members = yumush.chat.members.len();
37- let online = yumush
38- .chat
39- .members
40- .iter()
41- .filter(|member| yumush.presence_of(member.user.id) != Presence::Offline)
42- .count();
43- let pinned = yumush.chat.pinned.contains(&id);
44- let muted = yumush.chat.muted.contains(&id);
45- let can_leave = permission::can_leave(yumush.actor_rank());
46- let words_sidebar = &w().sidebar;
47- let row =
48- |key: &'static str,
49- label: &'static str,
50- icon: IconName,
51- color: Hsla,
52- run: fn(&mut Yumush, Id, &mut Window, &mut Context<Yumush>)| {
53- menu_row(
54- key,
55- label,
56- menu_icon(icon),
57- color,
58- palette,
59- yumush_action(&entity, &popover, move |yumush, window, cx| {
60- run(yumush, id, window, cx)
61- }),
62- )
63- };
64-
65- super::parts::popover(t)
66- .w(px(size::POPOVER))
67- .gap(px(space::LG))
68- .child(
69- band(space::LG)
70- .child(super::zoomable(
71- &entity,
72- "community_picture",
73- super::community_icon(
74- palette,
75- &community,
76- px(size::AVATAR_LG),
77- text(text::BODY),
78- &yumush.chat.avatars,
79- ),
80- super::Zoom::new(
81- super::picture_of(&community, &yumush.chat.avatars),
82- false,
83- name.clone(),
84- ),
85- ))
86- .child(
87- stack(space::XXS)
88- .flex_1()
89- .min_w_0()
90- .child(
91- words(name, Text::Body, Ink::Paper, t)
92- .font_weight(FontWeight::MEDIUM)
93- .truncate(),
94- )
95- .child(words(
96- w().community_card.people(members, online),
97- Text::Caption,
98- Ink::Dim,
99- t,
100- )),
101- ),
102- )
103- .child(div().w_full().h(px(stroke::LINE)).bg(t.thread()))
104- .child(
105- stack(space::XS)
106- .child(row(
107- "community_invite",
108- words_sidebar.invite,
109- IconName::UserPlus,
110- palette.text,
111- |yumush, id, window, cx| yumush.open_invite(id, window, cx),
112- ))
113- .child(row(
114- "community_settings",
115- words_sidebar.settings,
116- IconName::Settings,
117- palette.text,
118- |yumush, id, window, cx| yumush.open_community_settings(id, window, cx),
119- ))
120- .child(row(
121- "community_pin",
122- if pinned {
123- words_sidebar.unpin
124- } else {
125- words_sidebar.pin
126- },
127- IconName::Pin,
128- palette.text,
129- |yumush, id, _, cx| yumush.toggle_mark(Mark::Pin, id, cx),
130- ))
131- .child(row(
132- "community_mute",
133- if muted {
134- words_sidebar.unmute
135- } else {
136- words_sidebar.mute
137- },
138- if muted {
139- IconName::Bell
140- } else {
141- IconName::BellOff
142- },
143- palette.text,
144- |yumush, id, _, cx| yumush.toggle_mark(Mark::Mute, id, cx),
145- ))
146- .children(can_leave.then(|| {
147- row(
148- "community_leave",
149- words_sidebar.leave,
150- IconName::LogOut,
151- palette.danger,
152- |yumush, id, window, cx| yumush.leave_community(id, window, cx),
153- )
154- })),
155- )
156- })
157-}
crates/client/src/gui/composer.rsmodified+41 -35
@@ -541,43 +541,32 @@ pub(super) fn trigger_icon(
541 ))541 ))
542 }542 }
543 543
544-pub fn format_popover(palette: Palette) -> impl IntoElement {544+fn format_panel(palette: Palette) -> impl IntoElement {
545- Popover::new("format_popover")545+ panel(palette)
546- .anchor(Anchor::BottomLeft)546+ .w(px(size::SHEET))
547- .appearance(false)547+ .p(px(space::SM))
548- .trigger(trigger_icon(548+ .flex()
549- "format_trigger",549+ .flex_col()
550- IconName::Type,550+ .gap(px(space::SM))
551- size::CONTROL_SM,551+ .text_size(text(text::CAPTION))
552- palette,552+ .children(FORMAT_ROWS.map(|(syntax, shortcut)| {
553- ))553+ div()
554- .content(move |_, _, _| {
555- panel(palette)
556- .w(px(size::SHEET))
557- .p(px(space::SM))
558 .flex()554 .flex()
559- .flex_col()555+ .items_center()
560- .gap(px(space::SM))556+ .gap(px(space::MD))
561- .text_size(text(text::CAPTION))557+ .child(
562- .children(FORMAT_ROWS.map(|(syntax, shortcut)| {
563 div()558 div()
564- .flex()559+ .w(px(size::THUMB))
565- .items_center()560+ .text_color(palette.muted)
566- .gap(px(space::MD))561+ .child(syntax),
567- .child(562+ )
568- div()563+ .child(div().flex_1().child(TextView::markdown(syntax, syntax)))
569- .w(px(size::THUMB))564+ .child(
570- .text_color(palette.muted)565+ div()
571- .child(syntax),566+ .text_color(palette.muted)
572- )567+ .child(shortcut_label(shortcut)),
573- .child(div().flex_1().child(TextView::markdown(syntax, syntax)))568+ )
574- .child(569+ }))
575- div()
576- .text_color(palette.muted)
577- .child(shortcut_label(shortcut)),
578- )
579- }))
580- })
581 }570 }
582 571
583 #[derive(Clone, Copy, PartialEq, Eq, Default)]572 #[derive(Clone, Copy, PartialEq, Eq, Default)]
@@ -585,6 +574,7 @@ pub(super) enum PlusMenu {
585 #[default]574 #[default]
586 Menu,575 Menu,
587 Poll,576 Poll,
577+ Format,
588 }578 }
589 579
590 fn plus_row(580 fn plus_row(
@@ -640,9 +630,13 @@ pub fn plus_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i
640 ))630 ))
641 .content(move |_, _, cx| {631 .content(move |_, _, cx| {
642 let popover = cx.entity();632 let popover = cx.entity();
633+ if entity.read(cx).chat.plus_menu == PlusMenu::Format {
634+ return format_panel(palette).into_any_element();
635+ }
643 if entity.read(cx).chat.plus_menu == PlusMenu::Menu {636 if entity.read(cx).chat.plus_menu == PlusMenu::Menu {
644 let file = entity.clone();637 let file = entity.clone();
645 let poll = entity.clone();638 let poll = entity.clone();
639+ let format = entity.clone();
646 return panel(palette)640 return panel(palette)
647 .w(px(size::SIDEBAR))641 .w(px(size::SIDEBAR))
648 .p(px(space::XS))642 .p(px(space::XS))
@@ -671,6 +665,18 @@ pub fn plus_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> i
671 })665 })
672 },666 },
673 ))667 ))
668+ .child(plus_row(
669+ "plus_format",
670+ IconName::Type,
671+ w().composer.format,
672+ palette,
673+ move |_, cx| {
674+ format.update(cx, |yumush, cx| {
675+ yumush.chat.plus_menu = PlusMenu::Format;
676+ cx.notify();
677+ })
678+ },
679+ ))
674 .into_any_element();680 .into_any_element();
675 }681 }
676 let toggle = entity.clone();682 let toggle = entity.clone();
crates/client/src/gui/message_actions.rsmodified+74 -1
@@ -27,7 +27,7 @@ use super::{
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, primary_button, sidebar,
29 style::{radius, size, space, text},29 style::{radius, size, space, text},
30- widget::{field, icon_button, panel, spawn_done},30+ widget::{field, icon_button, panel, search_text, spawn_done},
31 };31 };
32 32
33 pub fn reactions(33 pub fn reactions(
@@ -229,6 +229,33 @@ fn jump_row(
229 )229 )
230 }230 }
231 231
232+fn person_row(
233+ user: &User,
234+ entity: &Entity<Yumush>,
235+ popover: &Entity<PopoverState>,
236+ palette: Palette,
237+) -> Stateful<Div> {
238+ let entity = entity.clone();
239+ let popover = popover.clone();
240+ let user_id = user.id;
241+
242+ clickable(
243+ format!("search_person_{user_id}"),
244+ palette,
245+ move |window, cx| {
246+ popover.update(cx, |state, cx| state.dismiss(window, cx));
247+ entity.update(cx, |yumush, cx| yumush.open_direct(user_id, window, cx));
248+ },
249+ )
250+ .flex()
251+ .items_center()
252+ .gap(px(space::SM))
253+ .px(px(space::SM))
254+ .py(px(space::XS))
255+ .rounded(px(radius::MD))
256+ .text_size(text(text::CAPTION))
257+}
258+
232 pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> impl IntoElement {259 pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) -> impl IntoElement {
233 let entity = entity.clone();260 let entity = entity.clone();
234 let input = chat.community_search.clone();261 let input = chat.community_search.clone();
@@ -258,6 +285,22 @@ pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) ->
258 ))285 ))
259 .content(move |_, _, cx| {286 .content(move |_, _, cx| {
260 let popover = cx.entity();287 let popover = cx.entity();
288+ let query = search_text(&input, cx);
289+ let yumush = entity.read(cx);
290+ let people: Vec<&User> = if query.is_empty() {
291+ vec![]
292+ } else {
293+ yumush
294+ .chat
295+ .members
296+ .iter()
297+ .map(|member| &member.user)
298+ .filter(|user| {
299+ !yumush.is_me(user.id) && user.username.to_lowercase().contains(&query)
300+ })
301+ .take(5)
302+ .collect()
303+ };
261 panel(palette)304 panel(palette)
262 .w(px(size::POPOVER))305 .w(px(size::POPOVER))
263 .p(px(space::XS))306 .p(px(space::XS))
@@ -265,6 +308,36 @@ pub fn search_popover(chat: &Chat, entity: &Entity<Yumush>, palette: Palette) ->
265 .flex_col()308 .flex_col()
266 .gap(px(space::XS))309 .gap(px(space::XS))
267 .child(sidebar::input_box(&input, palette))310 .child(sidebar::input_box(&input, palette))
311+ .children((!people.is_empty()).then(|| {
312+ div()
313+ .px(px(space::SM))
314+ .text_size(text(text::CAPTION))
315+ .text_color(palette.muted)
316+ .child(w().message_actions.people)
317+ }))
318+ .children(people.iter().map(|user| {
319+ person_row(user, &entity, &popover, palette)
320+ .child(avatar(
321+ palette,
322+ user,
323+ px(size::ICON_SM),
324+ text(text::CAPTION),
325+ &yumush.chat.avatars,
326+ ))
327+ .child(
328+ div()
329+ .flex_shrink_0()
330+ .font_weight(FontWeight::SEMIBOLD)
331+ .child(user.username.clone()),
332+ )
333+ }))
334+ .children((!query.is_empty() && !hits.is_empty()).then(|| {
335+ div()
336+ .px(px(space::SM))
337+ .text_size(text(text::CAPTION))
338+ .text_color(palette.muted)
339+ .child(w().message_actions.messages)
340+ }))
268 .children(hits.iter().map(|hit| {341 .children(hits.iter().map(|hit| {
269 jump_row("search_hit", hit, &entity, &popover, palette)342 jump_row("search_hit", hit, &entity, &popover, palette)
270 .children(hit.time.as_ref().map(|time| {343 .children(hit.time.as_ref().map(|time| {