mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 19:10:24 +00:00
🎨
This commit is contained in:
parent
0f4598a243
commit
7dae21cb36
2 changed files with 6 additions and 10 deletions
|
@ -49,6 +49,7 @@ impl BeginTransaction for Db<sqlx::Postgres> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In Sqlite, transactions are inherently serializable.
|
// In Sqlite, transactions are inherently serializable.
|
||||||
|
#[cfg(test)]
|
||||||
impl BeginTransaction for Db<sqlx::Sqlite> {
|
impl BeginTransaction for Db<sqlx::Sqlite> {
|
||||||
type Database = sqlx::Sqlite;
|
type Database = sqlx::Sqlite;
|
||||||
|
|
||||||
|
@ -1141,10 +1142,7 @@ where
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn leave_room_for_connection(
|
pub async fn leave_room(&self, connection_id: ConnectionId) -> Result<Option<LeftRoom>> {
|
||||||
&self,
|
|
||||||
connection_id: ConnectionId,
|
|
||||||
) -> Result<Option<LeftRoom>> {
|
|
||||||
self.transact(|mut tx| async move {
|
self.transact(|mut tx| async move {
|
||||||
// Leave room.
|
// Leave room.
|
||||||
let room_id = sqlx::query_scalar::<_, RoomId>(
|
let room_id = sqlx::query_scalar::<_, RoomId>(
|
||||||
|
@ -1498,8 +1496,7 @@ where
|
||||||
.bind(user_id)
|
.bind(user_id)
|
||||||
.bind(connection_id.0 as i32)
|
.bind(connection_id.0 as i32)
|
||||||
.fetch_one(&mut tx)
|
.fetch_one(&mut tx)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if !worktrees.is_empty() {
|
if !worktrees.is_empty() {
|
||||||
let mut params = "(?, ?, ?, ?, ?, ?, ?),".repeat(worktrees.len());
|
let mut params = "(?, ?, ?, ?, ?, ?, ?),".repeat(worktrees.len());
|
||||||
|
@ -1530,7 +1527,7 @@ where
|
||||||
.bind(0)
|
.bind(0)
|
||||||
.bind(false);
|
.bind(false);
|
||||||
}
|
}
|
||||||
query.execute(&mut tx).await.unwrap();
|
query.execute(&mut tx).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
|
@ -1551,8 +1548,7 @@ where
|
||||||
.bind(0)
|
.bind(0)
|
||||||
.bind(true)
|
.bind(true)
|
||||||
.execute(&mut tx)
|
.execute(&mut tx)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let room = self.commit_room_transaction(room_id, tx).await?;
|
let room = self.commit_room_transaction(room_id, tx).await?;
|
||||||
Ok((project_id, room))
|
Ok((project_id, room))
|
||||||
|
|
|
@ -629,7 +629,7 @@ impl Server {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut contacts_to_update = HashSet::default();
|
let mut contacts_to_update = HashSet::default();
|
||||||
|
|
||||||
let Some(left_room) = self.app_state.db.leave_room_for_connection(leaving_connection_id).await? else {
|
let Some(left_room) = self.app_state.db.leave_room(leaving_connection_id).await? else {
|
||||||
return Err(anyhow!("no room to leave"))?;
|
return Err(anyhow!("no room to leave"))?;
|
||||||
};
|
};
|
||||||
contacts_to_update.insert(leaving_user_id);
|
contacts_to_update.insert(leaving_user_id);
|
||||||
|
|
Loading…
Reference in a new issue