From db97dcd76f74580af3ec5f210c3b37dcd517b5ef Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 2 Jun 2022 17:41:21 -0700 Subject: [PATCH] Don't update contacts when a project is first registered Until the host has sent an UpdateProject message to populate the project's metadata, there is no reason to update contacts. --- crates/collab/src/rpc.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index c19538f55c..a3eb64034b 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -476,15 +476,15 @@ impl Server { request: TypedEnvelope, response: Response, ) -> Result<()> { - let user_id; let project_id; { let mut state = self.store_mut().await; - user_id = state.user_id_for_connection(request.sender_id)?; + let user_id = state.user_id_for_connection(request.sender_id)?; project_id = state.register_project(request.sender_id, user_id); }; + response.send(proto::RegisterProjectResponse { project_id })?; - self.update_user_contacts(user_id).await?; + Ok(()) } @@ -528,8 +528,13 @@ impl Server { } } + // Send out the `UpdateContacts` message before responding to the unregister + // request. This way, when the project's host can keep track of the project's + // remote id until after they've received the `UpdateContacts` message for + // themself. self.update_user_contacts(user_id).await?; response.send(proto::Ack {})?; + Ok(()) }