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};
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 ActiveCall::global(cx).update(cx, |call, cx| {
48 call.toggle_screen_sharing(cx);
49 });
50}
51
52pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
53 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
54 room.update(cx, Room::toggle_mute)
55 .map(|task| task.detach_and_log_err(cx))
56 .log_err();
57 }
58}
59
60pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
61 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
62 room.update(cx, Room::toggle_deafen)
63 .map(|task| task.detach_and_log_err(cx))
64 .log_err();
65 }
66}
67
68pub fn share_microphone(_: &ShareMicrophone, cx: &mut AppContext) {
69 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
70 room.update(cx, Room::share_microphone)
71 .detach_and_log_err(cx)
72 }
73}