2023-08-03 18:40:55 +00:00
|
|
|
pub mod collab_panel;
|
2022-09-28 17:14:31 +00:00
|
|
|
mod collab_titlebar_item;
|
2022-10-06 12:00:14 +00:00
|
|
|
mod contact_notification;
|
2023-02-21 21:12:11 +00:00
|
|
|
mod face_pile;
|
2022-09-29 13:33:33 +00:00
|
|
|
mod incoming_call_notification;
|
2022-10-06 12:00:14 +00:00
|
|
|
mod notifications;
|
2022-10-04 14:55:41 +00:00
|
|
|
mod project_shared_notification;
|
2023-02-03 19:17:50 +00:00
|
|
|
mod sharing_status_indicator;
|
2022-09-28 17:14:31 +00:00
|
|
|
|
2023-06-20 16:32:16 +00:00
|
|
|
use call::{ActiveCall, Room};
|
2023-07-24 21:39:16 +00:00
|
|
|
pub use collab_titlebar_item::CollabTitlebarItem;
|
2023-07-12 20:09:39 +00:00
|
|
|
use gpui::{actions, AppContext, Task};
|
2022-10-04 14:55:41 +00:00
|
|
|
use std::sync::Arc;
|
2023-06-20 19:36:36 +00:00
|
|
|
use util::ResultExt;
|
2023-04-28 09:12:09 +00:00
|
|
|
use workspace::AppState;
|
2022-09-28 17:14:31 +00:00
|
|
|
|
2023-06-22 11:49:36 +00:00
|
|
|
actions!(
|
|
|
|
collab,
|
2023-07-19 19:34:24 +00:00
|
|
|
[ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
|
2023-06-22 11:49:36 +00:00
|
|
|
);
|
2023-02-03 19:17:50 +00:00
|
|
|
|
2023-04-28 09:12:09 +00:00
|
|
|
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
2023-07-10 15:18:12 +00:00
|
|
|
vcs_menu::init(cx);
|
2022-10-06 14:10:45 +00:00
|
|
|
collab_titlebar_item::init(cx);
|
2023-08-03 18:40:55 +00:00
|
|
|
collab_panel::init(app_state.client.clone(), cx);
|
2023-04-28 09:12:09 +00:00
|
|
|
incoming_call_notification::init(&app_state, cx);
|
|
|
|
project_shared_notification::init(&app_state, cx);
|
2023-02-03 19:17:50 +00:00
|
|
|
sharing_status_indicator::init(cx);
|
2022-10-05 13:02:57 +00:00
|
|
|
|
2023-02-03 19:17:50 +00:00
|
|
|
cx.add_global_action(toggle_screen_sharing);
|
2023-06-16 18:16:36 +00:00
|
|
|
cx.add_global_action(toggle_mute);
|
|
|
|
cx.add_global_action(toggle_deafen);
|
2023-02-03 19:17:50 +00:00
|
|
|
}
|
2022-10-05 13:02:57 +00:00
|
|
|
|
2023-04-06 21:49:03 +00:00
|
|
|
pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
|
2023-07-12 20:09:39 +00:00
|
|
|
let call = ActiveCall::global(cx).read(cx);
|
|
|
|
if let Some(room) = call.room().cloned() {
|
|
|
|
let client = call.client();
|
|
|
|
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
|
|
|
if room.is_screen_sharing() {
|
|
|
|
ActiveCall::report_call_event_for_room(
|
|
|
|
"disable screen share",
|
|
|
|
room.id(),
|
|
|
|
&client,
|
|
|
|
cx,
|
|
|
|
);
|
|
|
|
Task::ready(room.unshare_screen(cx))
|
|
|
|
} else {
|
|
|
|
ActiveCall::report_call_event_for_room(
|
|
|
|
"enable screen share",
|
|
|
|
room.id(),
|
|
|
|
&client,
|
|
|
|
cx,
|
|
|
|
);
|
|
|
|
room.share_screen(cx)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
toggle_screen_sharing.detach_and_log_err(cx);
|
|
|
|
}
|
2023-02-03 19:17:50 +00:00
|
|
|
}
|
2023-06-16 18:16:36 +00:00
|
|
|
|
|
|
|
pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
|
2023-07-20 20:00:11 +00:00
|
|
|
let call = ActiveCall::global(cx).read(cx);
|
2023-07-20 20:21:21 +00:00
|
|
|
if let Some(room) = call.room().cloned() {
|
2023-07-20 20:00:11 +00:00
|
|
|
let client = call.client();
|
|
|
|
room.update(cx, |room, cx| {
|
|
|
|
if room.is_muted() {
|
|
|
|
ActiveCall::report_call_event_for_room("enable microphone", room.id(), &client, cx);
|
|
|
|
} else {
|
|
|
|
ActiveCall::report_call_event_for_room(
|
|
|
|
"disable microphone",
|
|
|
|
room.id(),
|
|
|
|
&client,
|
|
|
|
cx,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
room.toggle_mute(cx)
|
|
|
|
})
|
|
|
|
.map(|task| task.detach_and_log_err(cx))
|
|
|
|
.log_err();
|
2023-06-16 18:16:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
|
|
|
|
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
|
2023-06-20 19:36:36 +00:00
|
|
|
room.update(cx, Room::toggle_deafen)
|
|
|
|
.map(|task| task.detach_and_log_err(cx))
|
|
|
|
.log_err();
|
2023-06-16 18:16:36 +00:00
|
|
|
}
|
|
|
|
}
|