Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add deafening support
Piotr Osiewicza71180257d1c
diff --git a/crates/call2/src/call2.rs b/crates/call2/src/call2.rsindex 1cffc44f93a..d983af50b76 100644--- a/crates/call2/src/call2.rs+++ b/crates/call2/src/call2.rs@@ -686,6 +686,29 @@ impl CallHandler for Call {})});}+ fn toggle_deafen(&self, cx: &mut AppContext) {+ self.active_call.as_ref().map(|call| {+ call.0.update(cx, |this, cx| {+ this.room().map(|room| {+ room.update(cx, |this, cx| {+ this.toggle_deafen(cx).log_err();+ })+ })+ })+ });+ }+ fn is_deafened(&self, cx: &AppContext) -> Option<bool> {+ self.active_call+ .as_ref()+ .map(|call| {+ call.0+ .read(cx)+ .room()+ .map(|room| room.read(cx).is_deafened())+ })+ .flatten()+ .flatten()+ }}#[cfg(test)]diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rsindex 0ba5c3e7071..a58186d0f0d 100644--- a/crates/collab_ui2/src/collab_titlebar_item.rs+++ b/crates/collab_ui2/src/collab_titlebar_item.rs@@ -111,6 +111,17 @@ impl Render for CollabTitlebarItem {} else {ui::Icon::Mic};+ let speakers_icon = if self+ .workspace+ .update(cx, |this, cx| this.call_state().is_deafened(cx))+ .log_err()+ .flatten()+ .unwrap_or_default()+ {+ ui::Icon::AudioOff+ } else {+ ui::Icon::AudioOn+ };let workspace = self.workspace.clone();h_stack().id("titlebar")@@ -233,7 +244,16 @@ impl Render for CollabTitlebarItem {.log_err();}}))- .child(IconButton::new("mute-sound", ui::Icon::AudioOn))+ .child(IconButton::new("mute-sound", speakers_icon).on_click({+ let workspace = workspace.clone();+ move |_, cx| {+ workspace+ .update(cx, |this, cx| {+ this.call_state().toggle_deafen(cx);+ })+ .log_err();+ }+ })).child(IconButton::new("screen-share", ui::Icon::Screen).on_click(move |_, cx| {workspacediff --git a/crates/collab_ui2/src/face_pile.rs b/crates/collab_ui2/src/face_pile.rsindex 953470b8540..61a2ef85b5b 100644--- a/crates/collab_ui2/src/face_pile.rs+++ b/crates/collab_ui2/src/face_pile.rs@@ -17,7 +17,7 @@ impl RenderOnce for FacePile {let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| {let isnt_last = ix < player_count - 1;- div().when(isnt_last, |div| div.neg_mr_2()).child(player)+ div().when(isnt_last, |div| div.neg_mr_1()).child(player)});div().p_1().flex().items_center().children(player_list)}diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rsindex 73bfc633328..f906a194983 100644--- a/crates/workspace2/src/workspace2.rs+++ b/crates/workspace2/src/workspace2.rs@@ -371,6 +371,12 @@ impl CallHandler for TestCallHandler {fn toggle_mute(&self, cx: &mut AppContext) {}fn toggle_screen_share(&self, cx: &mut AppContext) {}++ fn toggle_deafen(&self, cx: &mut AppContext) {}++ fn is_deafened(&self, cx: &AppContext) -> Option<bool> {+ None+ }}impl AppState {@@ -483,7 +489,9 @@ pub trait CallHandler {) -> Task<Result<()>>;fn remote_participants(&self, cx: &AppContext) -> Option<Vec<(Arc<User>, PeerId)>>;fn is_muted(&self, cx: &AppContext) -> Option<bool>;+ fn is_deafened(&self, cx: &AppContext) -> Option<bool>;fn toggle_mute(&self, cx: &mut AppContext);+ fn toggle_deafen(&self, cx: &mut AppContext);fn toggle_screen_share(&self, cx: &mut AppContext);}