forge
Explore
Log in

Don't you dare go Hollow

1:1 call line shows only the other side's sound

Browse files at this commit

678a8d716cc21d20f780b58a490e575d9cf77893Ahmet Kaan GümüşParent: 3f99fc4
  • feat
    • 1:1 call line shows only the other side's sound
    • search in the community People column
  • fix
    • offline no longer hides you in 1:1 calls (the peer never saw your call ring)
Show full message
✨ feat: 1:1 call line shows only the other side's sound; search in the community People column; 🐛 fix: offline no longer hides you in 1:1 calls (the peer never saw your call ring)
crates/client/src/gui/chat.rsmodified+15 -1
@@ -145,6 +145,7 @@ pub struct Chat {
145 pub(super) muted: HashSet<Id>,145 pub(super) muted: HashSet<Id>,
146 pub(super) message_input: Entity<TextareaState>,146 pub(super) message_input: Entity<TextareaState>,
147 pub(super) search_input: Entity<InputState>,147 pub(super) search_input: Entity<InputState>,
148+ pub(super) member_input: Entity<InputState>,
148 pub(super) community_search: Entity<InputState>,149 pub(super) community_search: Entity<InputState>,
149 pub(super) community_hits: Vec<MessageHit>,150 pub(super) community_hits: Vec<MessageHit>,
150 pub(super) found: Option<User>,151 pub(super) found: Option<User>,
@@ -336,6 +337,14 @@ impl Chat {
336 )337 )
337 .detach();338 .detach();
338 339
340+ let member_input = new_input("Find", window, cx);
341+ cx.subscribe_in(&member_input, window, |_, _, event, _, cx| {
342+ if matches!(event, InputEvent::Change) {
343+ cx.notify();
344+ }
345+ })
346+ .detach();
347+
339 let search_input = new_input("Find user", window, cx);348 let search_input = new_input("Find user", window, cx);
340 cx.subscribe_in(349 cx.subscribe_in(
341 &search_input,350 &search_input,
@@ -412,6 +421,7 @@ impl Chat {
412 muted: HashSet::new(),421 muted: HashSet::new(),
413 message_input,422 message_input,
414 search_input,423 search_input,
424+ member_input,
415 community_search,425 community_search,
416 community_hits: vec![],426 community_hits: vec![],
417 found: None,427 found: None,
@@ -1405,7 +1415,7 @@ impl Yumush {
1405 },1415 },
1406 }1416 }
1407 }))1417 }))
1408- .children(members_column(entity, self, themed)),1418+ .children(members_column(entity, self, themed, cx)),
1409 ),1419 ),
1410 None => panel.child(empty_state(palette)),1420 None => panel.child(empty_state(palette)),
1411 },1421 },
@@ -2779,6 +2789,7 @@ fn members_column(
2779 entity: &Entity<Yumush>,2789 entity: &Entity<Yumush>,
2780 yumush: &Yumush,2790 yumush: &Yumush,
2781 palette: Palette,2791 palette: Palette,
2792+ cx: &App,
2782 ) -> Option<gpui_kit::Stateful<Div>> {2793 ) -> Option<gpui_kit::Stateful<Div>> {
2783 let chat = &yumush.chat;2794 let chat = &yumush.chat;
2784 let community_id = chat.selected_community_id?;2795 let community_id = chat.selected_community_id?;
@@ -2789,9 +2800,11 @@ fn members_column(
2789 return None;2800 return None;
2790 }2801 }
2791 let voice = chat.voice_ids(community_id);2802 let voice = chat.voice_ids(community_id);
2803+ let query = search_text(&chat.member_input, cx);
2792 let members: Vec<MemberRow> = chat2804 let members: Vec<MemberRow> = chat
2793 .members2805 .members
2794 .iter()2806 .iter()
2807+ .filter(|member| member.user.username.to_lowercase().contains(&query))
2795 .map(|member| MemberRow {2808 .map(|member| MemberRow {
2796 user: member.user.clone(),2809 user: member.user.clone(),
2797 rank: chat.rank_of(&member.user),2810 rank: chat.rank_of(&member.user),
@@ -2905,6 +2918,7 @@ fn members_column(
2905 .gap(px(space::LG))2918 .gap(px(space::LG))
2906 .border_l_1()2919 .border_l_1()
2907 .border_color(palette.border)2920 .border_color(palette.border)
2921+ .child(super::sidebar::input_box(&chat.member_input, palette))
2908 .children(section("In call", in_call))2922 .children(section("In call", in_call))
2909 .children(section("Online", online))2923 .children(section("Online", online))
2910 .children(section("Offline", offline)),2924 .children(section("Offline", offline)),
crates/client/src/gui/sidebar.rsmodified+10 -4
@@ -170,7 +170,13 @@ impl Yumush {
170 fn voice_chip(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> AnyElement {170 fn voice_chip(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> AnyElement {
171 let ids = self.chat.voice_ids(community_id);171 let ids = self.chat.voice_ids(community_id);
172 let t = palette.tokens;172 let t = palette.tokens;
173- let mut speakers = ids173+ let direct = self.is_direct(community_id);
174+ let heard: Vec<Id> = ids
175+ .iter()
176+ .copied()
177+ .filter(|id| !(direct && self.is_me(*id)))
178+ .collect();
179+ let mut speakers = heard
174 .iter()180 .iter()
175 .filter(|id| self.chat.waves.speaking.contains(id));181 .filter(|id| self.chat.waves.speaking.contains(id));
176 let voice = match (speakers.next(), speakers.next()) {182 let voice = match (speakers.next(), speakers.next()) {
@@ -178,7 +184,7 @@ impl Yumush {
178 (Some(_), Some(_)) => super::parts::Voice::Live(t.paper()),184 (Some(_), Some(_)) => super::parts::Voice::Live(t.paper()),
179 _ => super::parts::Voice::Quiet,185 _ => super::parts::Voice::Quiet,
180 };186 };
181- let total = self.chat.waves.total(ids);187+ let total = self.chat.waves.total(&heard);
182 let own = self.chat.voice_community() == Some(community_id);188 let own = self.chat.voice_community() == Some(community_id);
183 let folded = self.chat.call_folded;189 let folded = self.chat.call_folded;
184 let fold = entity.clone();190 let fold = entity.clone();
@@ -194,7 +200,7 @@ impl Yumush {
194 .h(px(space::MD))200 .h(px(space::MD))
195 .child(super::parts::voice_line(total.as_ref(), voice, t)),201 .child(super::parts::voice_line(total.as_ref(), voice, t)),
196 )202 )
197- .when(!self.is_direct(community_id), |this| {203+ .when(!direct, |this| {
198 this.child(204 this.child(
199 div()205 div()
200 .text_size(text(text::CAPTION))206 .text_size(text(text::CAPTION))
@@ -202,7 +208,7 @@ impl Yumush {
202 .child(ids.len().to_string()),208 .child(ids.len().to_string()),
203 )209 )
204 })210 })
205- .when(own, |this| {211+ .when(own && !direct, |this| {
206 this.child(212 this.child(
207 div()213 div()
208 .id(format!("call_fold_{community_id}"))214 .id(format!("call_fold_{community_id}"))
crates/server/src/call/user.rsmodified+11 -2
@@ -67,13 +67,22 @@ impl Handle for UpdateHue {
67 impl Handle for UpdatePresence {67 impl Handle for UpdatePresence {
68 async fn handle(self, me: Me, cx: &mut Cx<'_>) -> Result<(), ServerError> {68 async fn handle(self, me: Me, cx: &mut Cx<'_>) -> Result<(), ServerError> {
69 let me = me.user()?;69 let me = me.user()?;
70- let was_hidden = crate::publish::hidden(me.id, cx.db).await;70+ let was_offline = db::user::presence(me.id, cx.db).await? == Presence::Offline;
71 db::user::update_presence(me.id, self.presence, cx.db).await?;71 db::user::update_presence(me.id, self.presence, cx.db).await?;
72 cx.out72 cx.out
73 .extend(presence_changed(&cx.sh.services.hub, me.id, cx.db).await?);73 .extend(presence_changed(&cx.sh.services.hub, me.id, cx.db).await?);
74 let hiding = self.presence == Presence::Offline;74 let hiding = self.presence == Presence::Offline;
75 let rooms = &cx.sh.services.rooms;75 let rooms = &cx.sh.services.rooms;
76- if let Some(community_id) = rooms.room_of(me.id).filter(|_| was_hidden != hiding)76+ let direct = match rooms.room_of(me.id) {
77+ Some(community_id) => matches!(
78+ db::community::kind_of(community_id, cx.db).await?,
79+ Some(db::community::Kind::Direct)
80+ ),
81+ None => false,
82+ };
83+ if let Some(community_id) = rooms
84+ .room_of(me.id)
85+ .filter(|_| was_offline != hiding && !direct)
77 && rooms.participants(community_id).contains(&me.id)86 && rooms.participants(community_id).contains(&me.id)
78 {87 {
79 let shares = rooms88 let shares = rooms
crates/server/src/call/voice.rsmodified+2 -2
@@ -118,7 +118,7 @@ impl Handle for ListShares {
118 let inside = rooms.room_of(me.id) == Some(self.community_id);118 let inside = rooms.room_of(me.id) == Some(self.community_id);
119 let mut shares = Vec::new();119 let mut shares = Vec::new();
120 for share in rooms.shares(self.community_id) {120 for share in rooms.shares(self.community_id) {
121- if inside || !crate::publish::hidden(share.user_id, cx.db).await {121+ if inside || !crate::publish::hidden(share.user_id, self.community_id, cx.db).await {
122 shares.push(share);122 shares.push(share);
123 }123 }
124 }124 }
@@ -221,7 +221,7 @@ impl Handle for ListVoiceParticipants {
221 let inside = rooms.room_of(me.id) == Some(self.community_id);221 let inside = rooms.room_of(me.id) == Some(self.community_id);
222 let mut ids = Vec::new();222 let mut ids = Vec::new();
223 for user_id in rooms.participants(self.community_id) {223 for user_id in rooms.participants(self.community_id) {
224- if inside || !crate::publish::hidden(user_id, cx.db).await {224+ if inside || !crate::publish::hidden(user_id, self.community_id, cx.db).await {
225 ids.push(user_id);225 ids.push(user_id);
226 }226 }
227 }227 }
crates/server/src/publish.rsmodified+6 -2
@@ -59,7 +59,7 @@ pub(crate) async fn publish(shared: &Shared, db: &Connection, broadcasts: Vec<Br
59 };59 };
60 let community = matches!(broadcast.to, To::Community(_) | To::CommunityExcept(..));60 let community = matches!(broadcast.to, To::Community(_) | To::CommunityExcept(..));
61 if let Some((community_id, user_id)) = voice_subject(&broadcast.down).filter(|_| community)61 if let Some((community_id, user_id)) = voice_subject(&broadcast.down).filter(|_| community)
62- && hidden(user_id, db).await62+ && hidden(user_id, community_id, db).await
63 {63 {
64 let mut insiders = shared.services.rooms.room_users(community_id);64 let mut insiders = shared.services.rooms.room_users(community_id);
65 insiders.push(user_id);65 insiders.push(user_id);
@@ -114,8 +114,12 @@ async fn resolve(shared: &Shared, to: &To, db: &Connection) -> Result<Vec<ConnId
114 Ok(ids)114 Ok(ids)
115 }115 }
116 116
117-pub(crate) async fn hidden(user_id: Id, db: &Connection) -> bool {117+pub(crate) async fn hidden(user_id: Id, community_id: Id, db: &Connection) -> bool {
118 matches!(db::user::presence(user_id, db).await, Ok(Presence::Offline))118 matches!(db::user::presence(user_id, db).await, Ok(Presence::Offline))
119+ && !matches!(
120+ db::community::kind_of(community_id, db).await,
121+ Ok(Some(db::community::Kind::Direct))
122+ )
119 }123 }
120 124
121 fn voice_subject(down: &Down) -> Option<(Id, Id)> {125 fn voice_subject(down: &Down) -> Option<(Id, Id)> {