Send a LeaveProject message when dropping a remote project

This commit is contained in:
Max Brunsfeld 2021-12-20 18:07:51 -08:00
parent a138955943
commit 870b73aa36

View File

@ -749,7 +749,8 @@ impl Entity for Project {
type Event = Event;
fn release(&mut self, cx: &mut gpui::MutableAppContext) {
if let ProjectClientState::Local { remote_id_rx, .. } = &self.client_state {
match &self.client_state {
ProjectClientState::Local { remote_id_rx, .. } => {
if let Some(project_id) = *remote_id_rx.borrow() {
let rpc = self.client.clone();
cx.spawn(|_| async move {
@ -760,6 +761,17 @@ impl Entity for Project {
.detach();
}
}
ProjectClientState::Remote { remote_id, .. } => {
let rpc = self.client.clone();
let project_id = *remote_id;
cx.spawn(|_| async move {
if let Err(err) = rpc.send(proto::LeaveProject { project_id }).await {
log::error!("error leaving project: {}", err);
}
})
.detach();
}
}
}
}