Show project root names when displaying incoming call notification

This commit is contained in:
Antonio Scandurra 2022-10-11 10:59:36 +02:00
parent e0b6b0df2a
commit bf488f2027
8 changed files with 81 additions and 23 deletions

View file

@ -541,13 +541,15 @@ async fn test_share_project(
deterministic.run_until_parked();
let call = incoming_call_b.borrow().clone().unwrap();
assert_eq!(call.caller.github_login, "user_a");
let project_id = call.initial_project_id.unwrap();
let initial_project = call.initial_project.unwrap();
active_call_b
.update(cx_b, |call, cx| call.accept_incoming(cx))
.await
.unwrap();
let client_b_peer_id = client_b.peer_id;
let project_b = client_b.build_remote_project(project_id, cx_b).await;
let project_b = client_b
.build_remote_project(initial_project.id, cx_b)
.await;
let replica_id_b = project_b.read_with(cx_b, |project, _| project.replica_id());
deterministic.run_until_parked();

View file

@ -176,9 +176,9 @@ impl Store {
.iter()
.map(|participant| participant.user_id)
.collect(),
initial_project_id: active_call
initial_project: active_call
.initial_project_id
.map(|project_id| project_id.to_proto()),
.and_then(|id| Self::build_participant_project(id, &self.projects)),
})
}
} else {
@ -572,7 +572,8 @@ impl Store {
.iter()
.map(|participant| participant.user_id)
.collect(),
initial_project_id: initial_project_id.map(|project_id| project_id.to_proto()),
initial_project: initial_project_id
.and_then(|id| Self::build_participant_project(id, &self.projects)),
},
))
}
@ -726,14 +727,6 @@ impl Store {
.iter_mut()
.find(|participant| participant.peer_id == host_connection_id.0)
.ok_or_else(|| anyhow!("no such room"))?;
participant.projects.push(proto::ParticipantProject {
id: project_id.to_proto(),
worktree_root_names: worktrees
.iter()
.filter(|worktree| worktree.visible)
.map(|worktree| worktree.root_name.clone())
.collect(),
});
connection.projects.insert(project_id);
self.projects.insert(
@ -767,6 +760,10 @@ impl Store {
},
);
participant
.projects
.extend(Self::build_participant_project(project_id, &self.projects));
Ok(room)
}
@ -1011,6 +1008,22 @@ impl Store {
Ok(connection_ids)
}
fn build_participant_project(
project_id: ProjectId,
projects: &BTreeMap<ProjectId, Project>,
) -> Option<proto::ParticipantProject> {
Some(proto::ParticipantProject {
id: project_id.to_proto(),
worktree_root_names: projects
.get(&project_id)?
.worktrees
.values()
.filter(|worktree| worktree.visible)
.map(|worktree| worktree.root_name.clone())
.collect(),
})
}
pub fn project_connection_ids(
&self,
project_id: ProjectId,