zed/crates/collab_ui/src/collab_ui.rs

70 lines
2.2 KiB
Rust
Raw Normal View History

mod collab_titlebar_item;
mod contact_finder;
mod contact_list;
mod contact_notification;
mod contacts_popover;
mod face_pile;
2022-09-29 13:33:33 +00:00
mod incoming_call_notification;
mod notifications;
mod project_shared_notification;
mod sharing_status_indicator;
2023-06-20 16:32:16 +00:00
use call::{ActiveCall, Room};
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
use gpui::{actions, AppContext, Task};
use std::sync::Arc;
2023-06-20 19:36:36 +00:00
use util::ResultExt;
2023-04-28 09:12:09 +00:00
use workspace::AppState;
actions!(collab, [ToggleScreenSharing, ToggleMute, ToggleDeafen, ShareMicrophone]);
2023-04-28 09:12:09 +00:00
pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
2022-10-06 14:10:45 +00:00
collab_titlebar_item::init(cx);
contact_list::init(cx);
contact_finder::init(cx);
contacts_popover::init(cx);
2023-04-28 09:12:09 +00:00
incoming_call_notification::init(&app_state, cx);
project_shared_notification::init(&app_state, cx);
sharing_status_indicator::init(cx);
cx.add_global_action(toggle_screen_sharing);
2023-06-16 18:16:36 +00:00
cx.add_global_action(toggle_mute);
cx.add_global_action(toggle_deafen);
cx.add_global_action(share_microphone);
}
pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
let toggle_screen_sharing = room.update(cx, |room, cx| {
if room.is_screen_sharing() {
Task::ready(room.unshare_screen(cx))
} else {
room.share_screen(cx)
}
});
toggle_screen_sharing.detach_and_log_err(cx);
}
}
2023-06-16 18:16:36 +00:00
pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
2023-06-20 19:36:36 +00:00
room.update(cx, Room::toggle_mute)
.map(|task| task.detach_and_log_err(cx))
.log_err();
2023-06-16 18:16:36 +00:00
}
}
pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
2023-06-20 19:36:36 +00:00
room.update(cx, Room::toggle_deafen)
.map(|task| task.detach_and_log_err(cx))
.log_err();
2023-06-16 18:16:36 +00:00
}
}
pub fn share_microphone(_: &ShareMicrophone, cx: &mut AppContext) {
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
room.update(cx, Room::share_microphone).detach_and_log_err(cx)
}
}