mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 08:31:04 +00:00
Refresh project collaborator connection id for rejoined projects
This commit is contained in:
parent
ec6f2a3ad4
commit
15f666a50a
1 changed files with 21 additions and 15 deletions
|
@ -1429,9 +1429,7 @@ impl Database {
|
||||||
let project_id = ProjectId::from_proto(rejoined_project.id);
|
let project_id = ProjectId::from_proto(rejoined_project.id);
|
||||||
let Some(project) = project::Entity::find_by_id(project_id)
|
let Some(project) = project::Entity::find_by_id(project_id)
|
||||||
.one(&*tx)
|
.one(&*tx)
|
||||||
.await? else {
|
.await? else { continue };
|
||||||
continue
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut worktrees = Vec::new();
|
let mut worktrees = Vec::new();
|
||||||
let db_worktrees = project.find_related(worktree::Entity).all(&*tx).await?;
|
let db_worktrees = project.find_related(worktree::Entity).all(&*tx).await?;
|
||||||
|
@ -1504,7 +1502,25 @@ impl Database {
|
||||||
let mut collaborators = project
|
let mut collaborators = project
|
||||||
.find_related(project_collaborator::Entity)
|
.find_related(project_collaborator::Entity)
|
||||||
.all(&*tx)
|
.all(&*tx)
|
||||||
.await?
|
.await?;
|
||||||
|
let self_collaborator = if let Some(self_collaborator_ix) = collaborators
|
||||||
|
.iter()
|
||||||
|
.position(|collaborator| collaborator.user_id == user_id)
|
||||||
|
{
|
||||||
|
collaborators.swap_remove(self_collaborator_ix)
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let old_connection_id = self_collaborator.connection();
|
||||||
|
project_collaborator::Entity::update(project_collaborator::ActiveModel {
|
||||||
|
connection_id: ActiveValue::set(connection.id as i32),
|
||||||
|
connection_server_id: ActiveValue::set(ServerId(connection.owner_id as i32)),
|
||||||
|
..self_collaborator.into_active_model()
|
||||||
|
})
|
||||||
|
.exec(&*tx)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let collaborators = collaborators
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|collaborator| ProjectCollaborator {
|
.map(|collaborator| ProjectCollaborator {
|
||||||
connection_id: collaborator.connection(),
|
connection_id: collaborator.connection(),
|
||||||
|
@ -1514,16 +1530,6 @@ impl Database {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let old_connection_id = if let Some(self_collaborator_ix) = collaborators
|
|
||||||
.iter()
|
|
||||||
.position(|collaborator| collaborator.user_id == user_id)
|
|
||||||
{
|
|
||||||
let self_collaborator = collaborators.swap_remove(self_collaborator_ix);
|
|
||||||
self_collaborator.connection_id
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
rejoined_projects.push(RejoinedProject {
|
rejoined_projects.push(RejoinedProject {
|
||||||
id: project_id,
|
id: project_id,
|
||||||
old_connection_id,
|
old_connection_id,
|
||||||
|
|
Loading…
Reference in a new issue