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