Ensure sharing the same project twice is idempotent

This commit is contained in:
Antonio Scandurra 2022-10-07 14:47:06 +02:00
parent d3cddfdced
commit 6fb5901d69
2 changed files with 16 additions and 0 deletions

View file

@ -299,6 +299,12 @@ impl Room {
project: ModelHandle<Project>,
cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> {
if project.read(cx).is_remote() {
return Task::ready(Err(anyhow!("can't share remote project")));
} else if let Some(project_id) = project.read(cx).remote_id() {
return Task::ready(Ok(project_id));
}
let request = self
.client
.request(proto::ShareProject { room_id: self.id() });