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 collab_titlebar_item::init(cx);
32 contact_list::init(cx);
33 contact_finder::init(cx);
34 contacts_popover::init(cx);
35 incoming_call_notification::init(&app_state, cx);
36 project_shared_notification::init(&app_state, cx);
37 sharing_status_indicator::init(cx);
38
39 cx.add_global_action(toggle_screen_sharing);
40 cx.add_global_action(toggle_mute);
41 cx.add_global_action(toggle_deafen);
42 cx.add_global_action(share_microphone);
43}
44
45pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
46 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
47 let toggle_screen_sharing = room.update(cx, |room, cx| {
48 if room.is_screen_sharing() {
49 Task::ready(room.unshare_screen(cx))
50 } else {
51 room.share_screen(cx)
52 }
53 });
54 toggle_screen_sharing.detach_and_log_err(cx);
55 }
56}
57
58pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
59 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
60 room.update(cx, Room::toggle_mute)
61 .map(|task| task.detach_and_log_err(cx))
62 .log_err();
63 }
64}
65
66pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
67 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
68 room.update(cx, Room::toggle_deafen)
69 .map(|task| task.detach_and_log_err(cx))
70 .log_err();
71 }
72}
73
74pub fn share_microphone(_: &ShareMicrophone, cx: &mut AppContext) {
75 if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
76 room.update(cx, Room::share_microphone)
77 .detach_and_log_err(cx)
78 }
79}