Allow sharing/unsharing of projects

This commit is contained in:
Antonio Scandurra 2021-12-21 12:45:20 +01:00
parent 17094ec542
commit 89c0b358a7
3 changed files with 65 additions and 3 deletions

View file

@ -357,6 +357,7 @@ impl Project {
for task in tasks {
task.await?;
}
this.update(&mut cx, |_, cx| cx.notify());
Ok(())
})
}
@ -371,7 +372,7 @@ impl Project {
..
} = &mut this.client_state
{
*is_shared = true;
*is_shared = false;
remote_id_rx
.borrow()
.ok_or_else(|| anyhow!("no project id"))
@ -381,7 +382,10 @@ impl Project {
})?;
rpc.send(proto::UnshareProject { project_id }).await?;
this.update(&mut cx, |this, cx| {
this.collaborators.clear();
cx.notify()
});
Ok(())
})
}
@ -396,6 +400,13 @@ impl Project {
}
}
pub fn is_local(&self) -> bool {
match &self.client_state {
ProjectClientState::Local { .. } => true,
ProjectClientState::Remote { .. } => false,
}
}
pub fn open_buffer(
&self,
path: ProjectPath,
@ -408,7 +419,7 @@ impl Project {
}
}
fn is_shared(&self) -> bool {
pub fn is_shared(&self) -> bool {
match &self.client_state {
ProjectClientState::Local { is_shared, .. } => *is_shared,
ProjectClientState::Remote { .. } => false,
@ -512,6 +523,7 @@ impl Project {
} = &mut self.client_state
{
*sharing_has_stopped = true;
self.collaborators.clear();
cx.notify();
Ok(())
} else {