collab_ui.rs

 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;
13pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
14use gpui::{actions, AppContext, Task};
15use std::sync::Arc;
16use workspace::AppState;
17
18actions!(collab, [ToggleScreenSharing]);
19
20pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
21    collab_titlebar_item::init(cx);
22    contact_list::init(cx);
23    contact_finder::init(cx);
24    contacts_popover::init(cx);
25    incoming_call_notification::init(&app_state, cx);
26    project_shared_notification::init(&app_state, cx);
27    sharing_status_indicator::init(cx);
28
29    cx.add_global_action(toggle_screen_sharing);
30}
31
32pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
33    if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
34        let toggle_screen_sharing = room.update(cx, |room, cx| {
35            if room.is_screen_sharing() {
36                Task::ready(room.unshare_screen(cx))
37            } else {
38                room.share_screen(cx)
39            }
40        });
41        toggle_screen_sharing.detach_and_log_err(cx);
42    }
43}