diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 5ca242cd0b..39bcb99f8e 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -269,20 +269,23 @@ impl CollabTitlebarItem { match self.collaborator_list_popover.take() { Some(_) => {} None => { - let view = cx.add_view(|cx| CollaboratorListPopover::new(cx)); + if let Some(workspace) = self.workspace.upgrade(cx) { + let user_store = workspace.read(cx).user_store().clone(); + let view = cx.add_view(|cx| CollaboratorListPopover::new(user_store, cx)); - cx.subscribe(&view, |this, _, event, cx| { - match event { - collaborator_list_popover::Event::Dismissed => { - this.collaborator_list_popover = None; + cx.subscribe(&view, |this, _, event, cx| { + match event { + collaborator_list_popover::Event::Dismissed => { + this.collaborator_list_popover = None; + } } - } - cx.notify(); - }) - .detach(); + cx.notify(); + }) + .detach(); - self.collaborator_list_popover = Some(view); + self.collaborator_list_popover = Some(view); + } } } cx.notify(); diff --git a/crates/collab_ui/src/collaborator_list_popover.rs b/crates/collab_ui/src/collaborator_list_popover.rs index fa36e202cd..cdc053d83f 100644 --- a/crates/collab_ui/src/collaborator_list_popover.rs +++ b/crates/collab_ui/src/collaborator_list_popover.rs @@ -1,5 +1,6 @@ use call::ActiveCall; -use gpui::{elements::*, Entity, MouseButton, RenderContext, View, ViewContext}; +use client::UserStore; +use gpui::{elements::*, Entity, ModelHandle, MouseButton, RenderContext, View, ViewContext}; use settings::Settings; use crate::collab_titlebar_item::ToggleCollaboratorList; @@ -45,22 +46,33 @@ impl View for CollaboratorListPopover { } impl CollaboratorListPopover { - pub fn new(cx: &mut ViewContext) -> Self { + pub fn new(user_store: ModelHandle, cx: &mut ViewContext) -> Self { let active_call = ActiveCall::global(cx); - let collaborator_count = active_call + + let mut collaborators = user_store .read(cx) - .room() - .map_or(0, |room| room.read(cx).remote_participants().len()); + .current_user() + .map(|u| u.github_login.clone()) + .into_iter() + .collect::>(); + + //TODO: What should the canonical sort here look like, consult contacts list implementation + if let Some(room) = active_call.read(cx).room() { + for participant in room.read(cx).remote_participants() { + collaborators.push(participant.1.user.github_login.clone()); + } + } + Self { list_state: ListState::new( - collaborator_count, + collaborators.len(), Orientation::Top, 0., cx, - |_, index, cx| { + move |_, index, cx| { let theme = &cx.global::().theme; Label::new( - format!("Participant {index}"), + collaborators[index].clone(), theme.contact_list.contact_username.text.clone(), ) .boxed()