Broadcast only visible worktree root names
This commit is contained in:
@@ -45,7 +45,7 @@ pub struct Contact {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ProjectMetadata {
|
||||
pub id: u64,
|
||||
pub worktree_root_names: Vec<String>,
|
||||
pub visible_worktree_root_names: Vec<String>,
|
||||
pub guests: BTreeSet<Arc<User>>,
|
||||
}
|
||||
|
||||
@@ -634,7 +634,7 @@ impl Contact {
|
||||
}
|
||||
projects.push(ProjectMetadata {
|
||||
id: project.id,
|
||||
worktree_root_names: project.worktree_root_names.clone(),
|
||||
visible_worktree_root_names: project.visible_worktree_root_names.clone(),
|
||||
guests,
|
||||
});
|
||||
}
|
||||
@@ -648,7 +648,7 @@ impl Contact {
|
||||
pub fn non_empty_projects(&self) -> impl Iterator<Item = &ProjectMetadata> {
|
||||
self.projects
|
||||
.iter()
|
||||
.filter(|project| !project.worktree_root_names.is_empty())
|
||||
.filter(|project| !project.visible_worktree_root_names.is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -608,7 +608,7 @@ async fn test_offline_projects(
|
||||
store.contacts()[0].projects,
|
||||
&[ProjectMetadata {
|
||||
id: project_id,
|
||||
worktree_root_names: vec!["crate1".into(), "crate2".into()],
|
||||
visible_worktree_root_names: vec!["crate1".into(), "crate2".into()],
|
||||
guests: Default::default(),
|
||||
}]
|
||||
);
|
||||
@@ -637,7 +637,7 @@ async fn test_offline_projects(
|
||||
store.contacts()[0].projects,
|
||||
&[ProjectMetadata {
|
||||
id: project_id,
|
||||
worktree_root_names: vec!["crate1".into(), "crate2".into()],
|
||||
visible_worktree_root_names: vec!["crate1".into(), "crate2".into()],
|
||||
guests: Default::default(),
|
||||
}]
|
||||
);
|
||||
@@ -655,7 +655,11 @@ async fn test_offline_projects(
|
||||
store.contacts()[0].projects,
|
||||
&[ProjectMetadata {
|
||||
id: project_id,
|
||||
worktree_root_names: vec!["crate1".into(), "crate2".into(), "crate3".into()],
|
||||
visible_worktree_root_names: vec![
|
||||
"crate1".into(),
|
||||
"crate2".into(),
|
||||
"crate3".into()
|
||||
],
|
||||
guests: Default::default(),
|
||||
}]
|
||||
);
|
||||
@@ -695,12 +699,16 @@ async fn test_offline_projects(
|
||||
&[
|
||||
ProjectMetadata {
|
||||
id: project_id,
|
||||
worktree_root_names: vec!["crate1".into(), "crate2".into(), "crate3".into()],
|
||||
visible_worktree_root_names: vec![
|
||||
"crate1".into(),
|
||||
"crate2".into(),
|
||||
"crate3".into()
|
||||
],
|
||||
guests: Default::default(),
|
||||
},
|
||||
ProjectMetadata {
|
||||
id: project2_id,
|
||||
worktree_root_names: vec!["crate3".into()],
|
||||
visible_worktree_root_names: vec!["crate3".into()],
|
||||
guests: Default::default(),
|
||||
}
|
||||
]
|
||||
@@ -3515,7 +3523,7 @@ async fn test_contacts(
|
||||
.iter()
|
||||
.map(|p| {
|
||||
(
|
||||
p.worktree_root_names[0].as_str(),
|
||||
p.visible_worktree_root_names[0].as_str(),
|
||||
p.guests.iter().map(|p| p.github_login.as_str()).collect(),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -277,9 +277,10 @@ impl Store {
|
||||
if project.host_user_id == user_id {
|
||||
metadata.push(proto::ProjectMetadata {
|
||||
id: project_id,
|
||||
worktree_root_names: project
|
||||
visible_worktree_root_names: project
|
||||
.worktrees
|
||||
.values()
|
||||
.filter(|worktree| worktree.visible)
|
||||
.map(|worktree| worktree.root_name.clone())
|
||||
.collect(),
|
||||
guests: project
|
||||
|
||||
@@ -462,7 +462,7 @@ impl ContactsPanel {
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
project.worktree_root_names.join(", "),
|
||||
project.visible_worktree_root_names.join(", "),
|
||||
row.name.text.clone(),
|
||||
)
|
||||
.aligned()
|
||||
@@ -847,7 +847,7 @@ impl ContactsPanel {
|
||||
p.read(cx).remote_id() == Some(project.id)
|
||||
})
|
||||
.map(|ix| open_projects.remove(ix).downgrade());
|
||||
if project.worktree_root_names.is_empty() {
|
||||
if project.visible_worktree_root_names.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(ContactEntry::ContactProject(
|
||||
@@ -872,7 +872,7 @@ impl ContactsPanel {
|
||||
self.entries.extend(
|
||||
contact.projects.iter().enumerate().filter_map(
|
||||
|(ix, project)| {
|
||||
if project.worktree_root_names.is_empty() {
|
||||
if project.visible_worktree_root_names.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(ContactEntry::ContactProject(
|
||||
@@ -1295,7 +1295,7 @@ mod tests {
|
||||
should_notify: false,
|
||||
projects: vec![proto::ProjectMetadata {
|
||||
id: 101,
|
||||
worktree_root_names: vec!["dir1".to_string()],
|
||||
visible_worktree_root_names: vec!["dir1".to_string()],
|
||||
guests: vec![2],
|
||||
}],
|
||||
},
|
||||
@@ -1305,7 +1305,7 @@ mod tests {
|
||||
should_notify: false,
|
||||
projects: vec![proto::ProjectMetadata {
|
||||
id: 102,
|
||||
worktree_root_names: vec!["dir2".to_string()],
|
||||
visible_worktree_root_names: vec!["dir2".to_string()],
|
||||
guests: vec![2],
|
||||
}],
|
||||
},
|
||||
@@ -1321,7 +1321,7 @@ mod tests {
|
||||
should_notify: false,
|
||||
projects: vec![proto::ProjectMetadata {
|
||||
id: 103,
|
||||
worktree_root_names: vec!["dir3".to_string()],
|
||||
visible_worktree_root_names: vec!["dir3".to_string()],
|
||||
guests: vec![3],
|
||||
}],
|
||||
},
|
||||
@@ -1425,12 +1425,12 @@ mod tests {
|
||||
projects: vec![
|
||||
proto::ProjectMetadata {
|
||||
id: 103,
|
||||
worktree_root_names: vec!["dir3".to_string()],
|
||||
visible_worktree_root_names: vec!["dir3".to_string()],
|
||||
guests: vec![3],
|
||||
},
|
||||
proto::ProjectMetadata {
|
||||
id: 200,
|
||||
worktree_root_names: vec!["private_dir".to_string()],
|
||||
visible_worktree_root_names: vec!["private_dir".to_string()],
|
||||
guests: vec![3],
|
||||
},
|
||||
],
|
||||
@@ -1489,7 +1489,7 @@ mod tests {
|
||||
should_notify: false,
|
||||
projects: vec![proto::ProjectMetadata {
|
||||
id: 103,
|
||||
worktree_root_names: vec!["dir3".to_string()],
|
||||
visible_worktree_root_names: vec!["dir3".to_string()],
|
||||
guests: vec![3],
|
||||
}],
|
||||
}],
|
||||
@@ -1611,7 +1611,9 @@ mod tests {
|
||||
.map(|project| project.read(cx));
|
||||
format!(
|
||||
" {}{}",
|
||||
contact.projects[*project_ix].worktree_root_names.join(", "),
|
||||
contact.projects[*project_ix]
|
||||
.visible_worktree_root_names
|
||||
.join(", "),
|
||||
if project.map_or(true, |project| project.is_online()) {
|
||||
""
|
||||
} else {
|
||||
|
||||
@@ -946,7 +946,7 @@ message Contact {
|
||||
|
||||
message ProjectMetadata {
|
||||
uint64 id = 1;
|
||||
repeated string worktree_root_names = 3;
|
||||
repeated string visible_worktree_root_names = 3;
|
||||
repeated uint64 guests = 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ impl WaitingRoom {
|
||||
login,
|
||||
humanize_list(
|
||||
&contact.projects[project_index]
|
||||
.worktree_root_names
|
||||
.visible_worktree_root_names
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -166,7 +166,7 @@ impl WaitingRoom {
|
||||
message: format!(
|
||||
"Asking to join @{}'s copy of {}...",
|
||||
contact.user.github_login,
|
||||
humanize_list(&contact.projects[project_index].worktree_root_names)
|
||||
humanize_list(&contact.projects[project_index].visible_worktree_root_names)
|
||||
),
|
||||
waiting: true,
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user