Filter out empty projects in contacts panel
This commit is contained in:
parent
ef868ff023
commit
4e9924c717
2 changed files with 126 additions and 113 deletions
|
@ -501,6 +501,12 @@ impl Contact {
|
||||||
}
|
}
|
||||||
Ok(Self { user, projects })
|
Ok(Self { user, projects })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn non_empty_projects(&self) -> impl Iterator<Item = &ProjectMetadata> {
|
||||||
|
self.projects
|
||||||
|
.iter()
|
||||||
|
.filter(|project| !project.worktree_root_names.is_empty())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_avatar(http: &dyn HttpClient, url: &str) -> Result<Arc<ImageData>> {
|
async fn fetch_avatar(http: &dyn HttpClient, url: &str) -> Result<Arc<ImageData>> {
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl ContactsPanel {
|
||||||
theme: &theme::ContactsPanel,
|
theme: &theme::ContactsPanel,
|
||||||
cx: &mut LayoutContext,
|
cx: &mut LayoutContext,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
let project_count = contact.projects.len();
|
let project_count = contact.non_empty_projects().count();
|
||||||
let font_cache = cx.font_cache();
|
let font_cache = cx.font_cache();
|
||||||
let line_height = theme.unshared_project.name.text.line_height(font_cache);
|
let line_height = theme.unshared_project.name.text.line_height(font_cache);
|
||||||
let cap_height = theme.unshared_project.name.text.cap_height(font_cache);
|
let cap_height = theme.unshared_project.name.text.cap_height(font_cache);
|
||||||
|
@ -188,17 +188,21 @@ impl ContactsPanel {
|
||||||
.with_height(theme.row_height)
|
.with_height(theme.row_height)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.with_children(contact.projects.iter().enumerate().map(|(ix, project)| {
|
.with_children(
|
||||||
|
contact
|
||||||
|
.non_empty_projects()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(ix, project)| {
|
||||||
let project_id = project.id;
|
let project_id = project.id;
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
Canvas::new(move |bounds, _, cx| {
|
Canvas::new(move |bounds, _, cx| {
|
||||||
let start_x =
|
let start_x = bounds.min_x() + (bounds.width() / 2.)
|
||||||
bounds.min_x() + (bounds.width() / 2.) - (tree_branch_width / 2.);
|
- (tree_branch_width / 2.);
|
||||||
let end_x = bounds.max_x();
|
let end_x = bounds.max_x();
|
||||||
let start_y = bounds.min_y();
|
let start_y = bounds.min_y();
|
||||||
let end_y = bounds.min_y() + baseline_offset - (cap_height / 2.);
|
let end_y =
|
||||||
|
bounds.min_y() + baseline_offset - (cap_height / 2.);
|
||||||
|
|
||||||
cx.scene.push_quad(gpui::Quad {
|
cx.scene.push_quad(gpui::Quad {
|
||||||
bounds: RectF::from_points(
|
bounds: RectF::from_points(
|
||||||
|
@ -271,7 +275,9 @@ impl ContactsPanel {
|
||||||
.aligned()
|
.aligned()
|
||||||
.left()
|
.left()
|
||||||
.contained()
|
.contained()
|
||||||
.with_margin_right(style.guest_avatar_spacing)
|
.with_margin_right(
|
||||||
|
style.guest_avatar_spacing,
|
||||||
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -302,7 +308,8 @@ impl ContactsPanel {
|
||||||
.constrained()
|
.constrained()
|
||||||
.with_height(theme.unshared_project.height)
|
.with_height(theme.unshared_project.height)
|
||||||
.boxed()
|
.boxed()
|
||||||
}))
|
}),
|
||||||
|
)
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue