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