diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 3b76a0bb378110a864b14a7e5bc536f87455e397..aa0cb1f20ef02c98e7d8eb4d7f317c885836497a 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -1143,6 +1143,17 @@ impl Room { }) } + pub fn toggle_mute(&mut self, cx: &mut ModelContext) -> Task> { + // https://docs.livekit.io/client/publish/ + // Should be acessible from local participant / publication + todo!(); + } + + pub fn toggle_deafen(&mut self, cx: &mut ModelContext) -> Task> { + // iterate through publications and mute (?????) + todo!(); + } + pub fn unshare_screen(&mut self, cx: &mut ModelContext) -> Result<()> { if self.status.is_offline() { return Err(anyhow!("room is offline")); diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index c0734388b1512b2e9cac5014c460bf1a8c09650b..9a426b0879f00a44ae7e2852a4c5074daaf63946 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -15,7 +15,7 @@ use gpui::{actions, AppContext, Task}; use std::sync::Arc; use workspace::AppState; -actions!(collab, [ToggleScreenSharing]); +actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen]); pub fn init(app_state: &Arc, cx: &mut AppContext) { collab_titlebar_item::init(cx); @@ -27,6 +27,8 @@ pub fn init(app_state: &Arc, cx: &mut AppContext) { sharing_status_indicator::init(cx); cx.add_global_action(toggle_screen_sharing); + cx.add_global_action(toggle_mute); + cx.add_global_action(toggle_deafen); } pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { @@ -41,3 +43,25 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) { toggle_screen_sharing.detach_and_log_err(cx); } } + +pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { + if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { + let toggle_mut = room.update(cx, |room, cx| { + if room.is_sharing_mic() { + room.toggle_mute(cx) + } else { + room.share_mic(cx) + } + }); + toggle_mut.detach_and_log_err(cx); + } +} + +pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) { + if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() { + let toggle_deafan = room.update(cx, |room, cx| { + room.toggle_deafen(cx) + }); + toggle_deafan.detach_and_log_err(cx); + } +}