Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix compilation errors after restructuring `room_transaction`
Antonio Scandurra74e0bed38f4b
diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rsindex da0bd51d5dc..a2939bf9ae5 100644--- a/crates/collab/src/db.rs+++ b/crates/collab/src/db.rs@@ -1715,8 +1715,8 @@ impl Database {leader_connection: ConnectionId,follower_connection: ConnectionId,) -> Result<RoomGuard<proto::Room>> {- self.room_transaction(|tx| async move {- let room_id = self.room_id_for_project(project_id, &*tx).await?;+ let room_id = self.room_id_for_project(project_id).await?;+ self.room_transaction(room_id, |tx| async move {follower::ActiveModel {room_id: ActiveValue::set(room_id),project_id: ActiveValue::set(project_id),@@ -1733,7 +1733,8 @@ impl Database {.insert(&*tx).await?;- Ok((room_id, self.get_room(room_id, &*tx).await?))+ let room = self.get_room(room_id, &*tx).await?;+ Ok(room)}).await}@@ -1744,8 +1745,8 @@ impl Database {leader_connection: ConnectionId,follower_connection: ConnectionId,) -> Result<RoomGuard<proto::Room>> {- self.room_transaction(|tx| async move {- let room_id = self.room_id_for_project(project_id, &*tx).await?;+ let room_id = self.room_id_for_project(project_id).await?;+ self.room_transaction(room_id, |tx| async move {follower::Entity::delete_many().filter(Condition::all()@@ -1767,30 +1768,12 @@ impl Database {.exec(&*tx).await?;- Ok((room_id, self.get_room(room_id, &*tx).await?))+ let room = self.get_room(room_id, &*tx).await?;+ Ok(room)}).await}- async fn room_id_for_project(- &self,- project_id: ProjectId,- tx: &DatabaseTransaction,- ) -> Result<RoomId> {- #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]- enum QueryAs {- RoomId,- }-- Ok(project::Entity::find_by_id(project_id)- .select_only()- .column(project::Column::RoomId)- .into_values::<_, QueryAs>()- .one(&*tx)- .await?- .ok_or_else(|| anyhow!("no such project"))?)- }-pub async fn update_room_participant_location(&self,room_id: RoomId,