mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Add deafening support
This commit is contained in:
parent
bf4211b03a
commit
a71180257d
@ -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)]
|
||||
|
@ -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| {
|
||||
workspace
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user