Detailed changes
@@ -48,6 +48,7 @@ pub struct Collaborator {
pub peer_id: proto::PeerId,
pub replica_id: ReplicaId,
pub user_id: UserId,
+ pub is_host: bool,
}
impl PartialOrd for User {
@@ -824,6 +825,7 @@ impl Collaborator {
peer_id: message.peer_id.ok_or_else(|| anyhow!("invalid peer id"))?,
replica_id: message.replica_id as ReplicaId,
user_id: message.user_id as UserId,
+ is_host: message.is_host,
})
}
}
@@ -740,6 +740,7 @@ impl ProjectCollaborator {
peer_id: Some(self.connection_id.into()),
replica_id: self.replica_id.0 as u32,
user_id: self.user_id.to_proto(),
+ is_host: self.is_host,
}
}
}
@@ -116,6 +116,7 @@ impl Database {
peer_id: Some(collaborator.connection().into()),
user_id: collaborator.user_id.to_proto(),
replica_id: collaborator.replica_id.0 as u32,
+ is_host: false,
})
.collect(),
})
@@ -222,6 +223,7 @@ impl Database {
peer_id: Some(collaborator.connection().into()),
user_id: collaborator.user_id.to_proto(),
replica_id: collaborator.replica_id.0 as u32,
+ is_host: false,
})
.collect(),
},
@@ -257,6 +259,7 @@ impl Database {
peer_id: Some(db_collaborator.connection().into()),
replica_id: db_collaborator.replica_id.0 as u32,
user_id: db_collaborator.user_id.to_proto(),
+ is_host: false,
})
} else {
collaborator_ids_to_remove.push(db_collaborator.id);
@@ -385,6 +388,7 @@ impl Database {
peer_id: Some(connection.into()),
replica_id: row.replica_id.0 as u32,
user_id: row.user_id.to_proto(),
+ is_host: false,
});
}
@@ -121,11 +121,13 @@ async fn test_channel_buffers(db: &Arc<Database>) {
user_id: a_id.to_proto(),
peer_id: Some(rpc::proto::PeerId { id: 1, owner_id }),
replica_id: 0,
+ is_host: false,
},
rpc::proto::Collaborator {
user_id: b_id.to_proto(),
peer_id: Some(rpc::proto::PeerId { id: 2, owner_id }),
replica_id: 1,
+ is_host: false,
}
]
);
@@ -1827,6 +1827,7 @@ fn join_project_internal(
peer_id: Some(session.connection_id.into()),
replica_id: replica_id.0 as u32,
user_id: guest_user_id.to_proto(),
+ is_host: false,
}),
};
@@ -1333,7 +1333,7 @@ impl Project {
}
pub fn host(&self) -> Option<&Collaborator> {
- self.collaborators.values().find(|c| c.replica_id == 0)
+ self.collaborators.values().find(|c| c.is_host)
}
pub fn set_worktrees_reordered(&mut self, worktrees_reordered: bool, cx: &mut AppContext) {
@@ -3495,7 +3495,7 @@ impl Project {
.collaborators
.remove(&old_peer_id)
.ok_or_else(|| anyhow!("received UpdateProjectCollaborator for unknown peer"))?;
- let is_host = collaborator.replica_id == 0;
+ let is_host = collaborator.is_host;
this.collaborators.insert(new_peer_id, collaborator);
log::info!("peer {} became {}", old_peer_id, new_peer_id,);
@@ -1721,6 +1721,7 @@ message Collaborator {
PeerId peer_id = 1;
uint32 replica_id = 2;
uint64 user_id = 3;
+ bool is_host = 4;
}
message User {
@@ -5715,7 +5715,7 @@ pub fn join_in_room_project(
.read(cx)
.collaborators()
.values()
- .find(|collaborator| collaborator.replica_id == 0)?;
+ .find(|collaborator| collaborator.is_host)?;
Some(collaborator.peer_id)
});