mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Allow calling an user, render contacts in collab panel
This commit is contained in:
parent
2a2b3b5e91
commit
e754c6626d
@ -549,42 +549,6 @@ impl Call {
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl CallHandler for Call {
|
||||
fn shared_screen_for_peer(
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
_pane: &View<Pane>,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) -> Option<Box<dyn ItemHandle>> {
|
||||
let (call, _) = self.active_call.as_ref()?;
|
||||
let room = call.read(cx).room()?.read(cx);
|
||||
let participant = room.remote_participant_for_peer_id(peer_id)?;
|
||||
let _track = participant.video_tracks.values().next()?.clone();
|
||||
let _user = participant.user.clone();
|
||||
todo!();
|
||||
// for item in pane.read(cx).items_of_type::<SharedScreen>() {
|
||||
// if item.read(cx).peer_id == peer_id {
|
||||
// return Box::new(Some(item));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Some(Box::new(cx.build_view(|cx| {
|
||||
// SharedScreen::new(&track, peer_id, user.clone(), cx)
|
||||
// })))
|
||||
}
|
||||
|
||||
fn room_id(&self, cx: &AppContext) -> Option<u64> {
|
||||
Some(self.active_call.as_ref()?.0.read(cx).room()?.read(cx).id())
|
||||
}
|
||||
fn hang_up(&self, mut cx: AsyncWindowContext) -> Result<Task<Result<()>>> {
|
||||
let Some((call, _)) = self.active_call.as_ref() else {
|
||||
bail!("Cannot exit a call; not in a call");
|
||||
};
|
||||
|
||||
call.update(&mut cx, |this, cx| this.hang_up(cx))
|
||||
}
|
||||
fn active_project(&self, cx: &AppContext) -> Option<WeakModel<Project>> {
|
||||
ActiveCall::global(cx).read(cx).location().cloned()
|
||||
}
|
||||
fn peer_state(
|
||||
&mut self,
|
||||
leader_id: PeerId,
|
||||
@ -618,6 +582,52 @@ impl CallHandler for Call {
|
||||
|
||||
Some((leader_in_this_project, leader_in_this_app))
|
||||
}
|
||||
|
||||
fn shared_screen_for_peer(
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
_pane: &View<Pane>,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) -> Option<Box<dyn ItemHandle>> {
|
||||
let (call, _) = self.active_call.as_ref()?;
|
||||
let room = call.read(cx).room()?.read(cx);
|
||||
let participant = room.remote_participant_for_peer_id(peer_id)?;
|
||||
let _track = participant.video_tracks.values().next()?.clone();
|
||||
let _user = participant.user.clone();
|
||||
todo!();
|
||||
// for item in pane.read(cx).items_of_type::<SharedScreen>() {
|
||||
// if item.read(cx).peer_id == peer_id {
|
||||
// return Box::new(Some(item));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Some(Box::new(cx.build_view(|cx| {
|
||||
// SharedScreen::new(&track, peer_id, user.clone(), cx)
|
||||
// })))
|
||||
}
|
||||
fn room_id(&self, cx: &AppContext) -> Option<u64> {
|
||||
Some(self.active_call.as_ref()?.0.read(cx).room()?.read(cx).id())
|
||||
}
|
||||
fn hang_up(&self, mut cx: AsyncWindowContext) -> Result<Task<Result<()>>> {
|
||||
let Some((call, _)) = self.active_call.as_ref() else {
|
||||
bail!("Cannot exit a call; not in a call");
|
||||
};
|
||||
|
||||
call.update(&mut cx, |this, cx| this.hang_up(cx))
|
||||
}
|
||||
fn active_project(&self, cx: &AppContext) -> Option<WeakModel<Project>> {
|
||||
ActiveCall::global(cx).read(cx).location().cloned()
|
||||
}
|
||||
fn invite(
|
||||
&mut self,
|
||||
called_user_id: u64,
|
||||
initial_project: Option<Model<Project>>,
|
||||
cx: &mut AppContext,
|
||||
) -> Task<Result<()>> {
|
||||
ActiveCall::global(cx).update(cx, |this, cx| {
|
||||
this.invite(called_user_id, initial_project, cx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -157,15 +157,17 @@ const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use client::{Client, Contact, UserStore};
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
actions, div, serde_json, AppContext, AsyncWindowContext, Div, EventEmitter, FocusHandle,
|
||||
Focusable, FocusableView, InteractiveElement, ParentElement, Render, View, ViewContext,
|
||||
VisualContext, WeakView,
|
||||
Focusable, FocusableView, InteractiveElement, Model, ParentElement, Render, Styled, View,
|
||||
ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use project::Fs;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use settings::Settings;
|
||||
use ui::{h_stack, Avatar, Label};
|
||||
use util::ResultExt;
|
||||
use workspace::{
|
||||
dock::{DockPosition, Panel, PanelEvent},
|
||||
@ -299,8 +301,8 @@ pub struct CollabPanel {
|
||||
// channel_editing_state: Option<ChannelEditingState>,
|
||||
// entries: Vec<ListEntry>,
|
||||
// selection: Option<usize>,
|
||||
// user_store: ModelHandle<UserStore>,
|
||||
// client: Arc<Client>,
|
||||
user_store: Model<UserStore>,
|
||||
client: Arc<Client>,
|
||||
// channel_store: ModelHandle<ChannelStore>,
|
||||
// project: ModelHandle<Project>,
|
||||
// match_candidates: Vec<StringMatchCandidate>,
|
||||
@ -595,7 +597,7 @@ impl CollabPanel {
|
||||
// entries: Vec::default(),
|
||||
// channel_editing_state: None,
|
||||
// selection: None,
|
||||
// user_store: workspace.user_store().clone(),
|
||||
user_store: workspace.user_store().clone(),
|
||||
// channel_store: ChannelStore::global(cx),
|
||||
// project: workspace.project().clone(),
|
||||
// subscriptions: Vec::default(),
|
||||
@ -603,7 +605,7 @@ impl CollabPanel {
|
||||
// collapsed_sections: vec![Section::Offline],
|
||||
// collapsed_channels: Vec::default(),
|
||||
_workspace: workspace.weak_handle(),
|
||||
// client: workspace.app_state().client.clone(),
|
||||
client: workspace.app_state().client.clone(),
|
||||
// context_menu_on_selected: true,
|
||||
// drag_target_channel: ChannelDragTarget::None,
|
||||
// list_state,
|
||||
@ -663,6 +665,9 @@ impl CollabPanel {
|
||||
})
|
||||
}
|
||||
|
||||
fn contacts(&self, cx: &AppContext) -> Option<Vec<Arc<Contact>>> {
|
||||
Some(self.user_store.read(cx).contacts().to_owned())
|
||||
}
|
||||
pub async fn load(
|
||||
workspace: WeakView<Workspace>,
|
||||
mut cx: AsyncWindowContext,
|
||||
@ -3297,11 +3302,32 @@ impl CollabPanel {
|
||||
impl Render for CollabPanel {
|
||||
type Element = Focusable<Div>;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let contacts = self.contacts(cx).unwrap_or_default();
|
||||
let workspace = self._workspace.clone();
|
||||
div()
|
||||
.key_context("CollabPanel")
|
||||
.track_focus(&self.focus_handle)
|
||||
.child("COLLAB PANEL")
|
||||
.children(contacts.into_iter().map(|contact| {
|
||||
let id = contact.user.id;
|
||||
h_stack()
|
||||
.p_2()
|
||||
.gap_2()
|
||||
.children(
|
||||
contact
|
||||
.user
|
||||
.avatar
|
||||
.as_ref()
|
||||
.map(|avatar| Avatar::new(avatar.clone())),
|
||||
)
|
||||
.child(Label::new(contact.user.github_login.clone()))
|
||||
.on_mouse_down(gpui::MouseButton::Left, {
|
||||
let workspace = workspace.clone();
|
||||
move |event, cx| {
|
||||
workspace.update(cx, |this, cx| this.call_state().invite(id, None, cx));
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,6 +454,12 @@ pub trait CallHandler {
|
||||
}
|
||||
fn hang_up(&self, cx: AsyncWindowContext) -> Result<Task<Result<()>>>;
|
||||
fn active_project(&self, cx: &AppContext) -> Option<WeakModel<Project>>;
|
||||
fn invite(
|
||||
&mut self,
|
||||
called_user_id: u64,
|
||||
initial_project: Option<Model<Project>>,
|
||||
cx: &mut AppContext,
|
||||
) -> Task<Result<()>>;
|
||||
}
|
||||
|
||||
pub struct Workspace {
|
||||
|
Loading…
Reference in New Issue
Block a user