Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Format
Conrad Irwinfbdca993ffc8
diff --git a/crates/collab/src/db/queries/channels.rs b/crates/collab/src/db/queries/channels.rsindex 95c9716a918..10b73a70941 100644--- a/crates/collab/src/db/queries/channels.rs+++ b/crates/collab/src/db/queries/channels.rs@@ -19,10 +19,7 @@ impl Database {#[cfg(test)]pub async fn create_root_channel(&self, name: &str, creator_id: UserId) -> Result<ChannelId> {- Ok(self- .create_channel(name, None, creator_id)- .await?- .id)+ Ok(self.create_channel(name, None, creator_id).await?.id)}#[cfg(test)]diff --git a/crates/collab/src/db/tests/message_tests.rs b/crates/collab/src/db/tests/message_tests.rsindex 22319ecc965..23c4da3a81f 100644--- a/crates/collab/src/db/tests/message_tests.rs+++ b/crates/collab/src/db/tests/message_tests.rs@@ -18,13 +18,9 @@ async fn test_channel_message_retrieval(db: &Arc<Database>) {let channel = db.create_channel("channel", None, user).await.unwrap();let owner_id = db.create_server("test").await.unwrap().0 as u32;- db.join_channel_chat(- channel.id,- rpc::ConnectionId { owner_id, id: 0 },- user,- )- .await- .unwrap();+ db.join_channel_chat(channel.id, rpc::ConnectionId { owner_id, id: 0 }, user)+ .await+ .unwrap();let mut all_messages = Vec::new();for i in 0..10 {@@ -366,11 +362,7 @@ async fn test_channel_message_mentions(db: &Arc<Database>) {let user_b = new_test_user(db, "[email protected]").await;let user_c = new_test_user(db, "[email protected]").await;- let channel = db- .create_channel("channel", None, user_a)- .await- .unwrap()- .id;+ let channel = db.create_channel("channel", None, user_a).await.unwrap().id;db.invite_channel_member(channel, user_b, user_a, ChannelRole::Member).await.unwrap();diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 415119bcd1c..bb173784d3c 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -3,11 +3,10 @@ mod connection_pool;use crate::{auth::{self, Impersonator},db::{- self, BufferId, ChannelId, ChannelRole, ChannelsForUser,- CreatedChannelMessage, Database, InviteMemberResult, MembershipUpdated, MessageId,- NotificationId, ProjectId, RemoveChannelMemberResult,- RenameChannelResult, RespondToChannelInvite, RoomId, ServerId, SetChannelVisibilityResult,- User, UserId,+ self, BufferId, ChannelId, ChannelRole, ChannelsForUser, CreatedChannelMessage, Database,+ InviteMemberResult, MembershipUpdated, MessageId, NotificationId, ProjectId,+ RemoveChannelMemberResult, RenameChannelResult, RespondToChannelInvite, RoomId, ServerId,+ SetChannelVisibilityResult, User, UserId,},executor::Executor,AppState, Error, Result,@@ -2570,53 +2569,57 @@ async fn move_channel(let channel_id = ChannelId::from_proto(request.channel_id);let to = request.to.map(ChannelId::from_proto);- let result = session.db().await.move_channel(channel_id, to, session.user_id).await?;+ let result = session+ .db()+ .await+ .move_channel(channel_id, to, session.user_id)+ .await?;if let Some(result) = result {- let participants_to_update: HashMap<_, _> = session.db().await- .new_participants_to_notify(- to.unwrap_or(channel_id)- )- .await?- .into_iter()- .collect();+ let participants_to_update: HashMap<_, _> = session+ .db()+ .await+ .new_participants_to_notify(to.unwrap_or(channel_id))+ .await?+ .into_iter()+ .collect();- let mut moved_channels: HashSet<ChannelId> = HashSet::default();- for id in result.descendent_ids {- moved_channels.insert(id);- }- moved_channels.insert(channel_id);+ let mut moved_channels: HashSet<ChannelId> = HashSet::default();+ for id in result.descendent_ids {+ moved_channels.insert(id);+ }+ moved_channels.insert(channel_id);- let mut participants_to_remove: HashSet<UserId> = HashSet::default();- for participant in result.previous_participants {- if participant.kind == proto::channel_member::Kind::AncestorMember {- if !participants_to_update.contains_key(&participant.user_id) {- participants_to_remove.insert(participant.user_id);- }- }+ let mut participants_to_remove: HashSet<UserId> = HashSet::default();+ for participant in result.previous_participants {+ if participant.kind == proto::channel_member::Kind::AncestorMember {+ if !participants_to_update.contains_key(&participant.user_id) {+ participants_to_remove.insert(participant.user_id);}+ }+ }- let moved_channels: Vec<u64> = moved_channels.iter().map(|id| id.to_proto()).collect();+ let moved_channels: Vec<u64> = moved_channels.iter().map(|id| id.to_proto()).collect();- let connection_pool = session.connection_pool().await;- for (user_id, channels) in participants_to_update {- let mut update = build_channels_update(channels, vec![]);- update.delete_channels = moved_channels.clone();- for connection_id in connection_pool.user_connection_ids(user_id) {- session.peer.send(connection_id, update.clone())?;- }- }+ let connection_pool = session.connection_pool().await;+ for (user_id, channels) in participants_to_update {+ let mut update = build_channels_update(channels, vec![]);+ update.delete_channels = moved_channels.clone();+ for connection_id in connection_pool.user_connection_ids(user_id) {+ session.peer.send(connection_id, update.clone())?;+ }+ }- for user_id in participants_to_remove {- let update = proto::UpdateChannels {- delete_channels: moved_channels.clone(),- ..Default::default()- };- for connection_id in connection_pool.user_connection_ids(user_id) {- session.peer.send(connection_id, update.clone())?;- }- }+ for user_id in participants_to_remove {+ let update = proto::UpdateChannels {+ delete_channels: moved_channels.clone(),+ ..Default::default()+ };+ for connection_id in connection_pool.user_connection_ids(user_id) {+ session.peer.send(connection_id, update.clone())?;+ }}+ }response.send(Ack {})?;Ok(())