Tell host to unshare project when last guest leaves
This commit is contained in:
@@ -634,6 +634,7 @@ impl Server {
|
|||||||
{
|
{
|
||||||
let mut state = self.store_mut().await;
|
let mut state = self.store_mut().await;
|
||||||
project = state.leave_project(sender_id, project_id)?;
|
project = state.leave_project(sender_id, project_id)?;
|
||||||
|
let unshare = project.connection_ids.len() <= 1;
|
||||||
broadcast(sender_id, project.connection_ids, |conn_id| {
|
broadcast(sender_id, project.connection_ids, |conn_id| {
|
||||||
self.peer.send(
|
self.peer.send(
|
||||||
conn_id,
|
conn_id,
|
||||||
@@ -643,6 +644,12 @@ impl Server {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
if unshare {
|
||||||
|
self.peer.send(
|
||||||
|
project.host_connection_id,
|
||||||
|
proto::ProjectUnshared { project_id },
|
||||||
|
)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.update_user_contacts(project.host_user_id).await?;
|
self.update_user_contacts(project.host_user_id).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ pub struct RemovedConnectionState {
|
|||||||
pub struct LeftProject {
|
pub struct LeftProject {
|
||||||
pub connection_ids: Vec<ConnectionId>,
|
pub connection_ids: Vec<ConnectionId>,
|
||||||
pub host_user_id: UserId,
|
pub host_user_id: UserId,
|
||||||
|
pub host_connection_id: ConnectionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@@ -504,6 +505,7 @@ impl Store {
|
|||||||
|
|
||||||
Ok(LeftProject {
|
Ok(LeftProject {
|
||||||
connection_ids: project.connection_ids(),
|
connection_ids: project.connection_ids(),
|
||||||
|
host_connection_id: project.host_connection_id,
|
||||||
host_user_id: project.host_user_id,
|
host_user_id: project.host_user_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user