1pub mod collab_panel;
2mod collab_titlebar_item;
3mod contact_notification;
4mod face_pile;
5mod incoming_call_notification;
6mod notifications;
7mod project_shared_notification;
8mod sharing_status_indicator;
9
10use call::{ActiveCall, Room};
11pub use collab_titlebar_item::CollabTitlebarItem;
12use gpui::{actions, AppContext, Task};
13use std::sync::Arc;
14use util::ResultExt;
15use workspace::AppState;
16
17actions!(
18 collab,
19 [ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
20);
21
22pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
23 vcs_menu::init(cx);
24 collab_titlebar_item::init(cx);
25 collab_panel::init(app_state.client.clone(), cx);
26 incoming_call_notification::init(&app_state, cx);
27 project_shared_notification::init(&app_state, cx);
28 sharing_status_indicator::init(cx);
29
30 cx.add_global_action(toggle_screen_sharing);
31 cx.add_global_action(toggle_mute);
32 cx.add_global_action(toggle_deafen);
33}
34
35pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
36 let call = ActiveCall::global(cx).read(cx);
37 if let Some(room) = call.room().cloned() {
38 let client = call.client();
39 let toggle_screen_sharing = room.update(cx, |room, cx| {
40 if room.is_screen_sharing() {
41 ActiveCall::report_call_event_for_room(
42 "disable screen share",
43 room.id(),
44 &client,
45 cx,
46 );
47 Task::ready(room.unshare_screen(cx))
48 } else {
49 ActiveCall::report_call_event_for_room(
50 "enable screen share",
51 room.id(),
52 &client,
53 cx,
54 );
55 room.share_screen(cx)
56 }
57 });
58 toggle_screen_sharing.detach_and_log_err(cx);
59 }
60}
61
62pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
63 let call = ActiveCall::global(cx).read(cx);
64 if let Some(room) = call.room().cloned() {
65 let client = call.client();
66 room.update(cx, |room, cx| {
67 if room.is_muted(cx) {
68 ActiveCall::report_call_event_for_room("enable microphone", room.id(), &client, cx);
69 } else {
70 ActiveCall::report_call_event_for_room(
71 "disable microphone",
72 room.id(),
73 &client,
74 cx,
75 );
76 }
77 room.toggle_mute(cx)
78 })
79 .map(|task| task.detach_and_log_err(cx))
80 .log_err();
81 }
82}
83
84pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
85 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
86 room.update(cx, Room::toggle_deafen)
87 .map(|task| task.detach_and_log_err(cx))
88 .log_err();
89 }
90}