From 65b8c512fed0d21ae55e35b02208a11dc2144018 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 11 Oct 2022 12:37:00 -0700 Subject: [PATCH] Allow opening other local projects via contacts list --- crates/collab_ui/src/contact_list.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index 7b773240cf..c04f0fe72d 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -65,7 +65,6 @@ enum ContactEntry { project_id: u64, worktree_root_names: Vec, host_user_id: u64, - is_host: bool, is_last: bool, }, IncomingRequest(Arc), @@ -181,6 +180,7 @@ impl ContactList { let list_state = ListState::new(0, Orientation::Top, 1000., cx, move |this, ix, cx| { let theme = cx.global::().theme.clone(); let is_selected = this.selection == Some(ix); + let current_project_id = this.project.read(cx).remote_id(); match &this.entries[ix] { ContactEntry::Header(section) => { @@ -205,13 +205,12 @@ impl ContactList { project_id, worktree_root_names, host_user_id, - is_host, is_last, } => Self::render_participant_project( *project_id, worktree_root_names, *host_user_id, - *is_host, + Some(*project_id) == current_project_id, *is_last, is_selected, &theme.contact_list, @@ -341,15 +340,12 @@ impl ContactList { ContactEntry::ParticipantProject { project_id, host_user_id, - is_host, .. } => { - if !is_host { - cx.dispatch_global_action(JoinProject { - project_id: *project_id, - follow_user_id: *host_user_id, - }); - } + cx.dispatch_global_action(JoinProject { + project_id: *project_id, + follow_user_id: *host_user_id, + }); } _ => {} } @@ -407,7 +403,6 @@ impl ContactList { project_id: project.id, worktree_root_names: project.worktree_root_names.clone(), host_user_id: user_id, - is_host: true, is_last: projects.peek().is_none(), }); } @@ -448,7 +443,6 @@ impl ContactList { project_id: project.id, worktree_root_names: project.worktree_root_names.clone(), host_user_id: participant.user.id, - is_host: false, is_last: projects.peek().is_none(), }); } @@ -667,7 +661,7 @@ impl ContactList { project_id: u64, worktree_root_names: &[String], host_user_id: u64, - is_host: bool, + is_current: bool, is_last: bool, is_selected: bool, theme: &theme::ContactList, @@ -749,13 +743,13 @@ impl ContactList { .with_style(row.container) .boxed() }) - .with_cursor_style(if !is_host { + .with_cursor_style(if !is_current { CursorStyle::PointingHand } else { CursorStyle::Arrow }) .on_click(MouseButton::Left, move |_, cx| { - if !is_host { + if !is_current { cx.dispatch_global_action(JoinProject { project_id, follow_user_id: host_user_id,