From 456396ca6e04de73e2d5d6e4748cc8f3b1754f22 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 9 Dec 2022 14:08:40 +0100 Subject: [PATCH] Rename `connection_lost` to `answering_connection_lost` --- .../migrations.sqlite/20221109000000_test_schema.sql | 2 +- ...165001_add_connection_lost_to_room_participants.sql | 2 +- crates/collab/src/db.rs | 10 +++++----- crates/collab/src/db/room_participant.rs | 2 +- crates/collab/src/rpc.rs | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index 9f03541f44..d1bb7b8f65 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -118,7 +118,7 @@ CREATE TABLE "room_participants" ( "user_id" INTEGER NOT NULL REFERENCES users (id), "answering_connection_id" INTEGER, "answering_connection_epoch" TEXT, - "connection_lost" BOOLEAN NOT NULL, + "answering_connection_lost" BOOLEAN NOT NULL, "location_kind" INTEGER, "location_project_id" INTEGER, "initial_project_id" INTEGER, diff --git a/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql b/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql index d49eda41b8..2f4f38407c 100644 --- a/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql +++ b/crates/collab/migrations/20221207165001_add_connection_lost_to_room_participants.sql @@ -1,2 +1,2 @@ ALTER TABLE "room_participants" - ADD "connection_lost" BOOLEAN NOT NULL DEFAULT FALSE; + ADD "answering_connection_lost" BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 5ab2b1b824..c21ef7026c 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -1034,7 +1034,7 @@ impl Database { user_id: ActiveValue::set(user_id), answering_connection_id: ActiveValue::set(Some(connection_id.0 as i32)), answering_connection_epoch: ActiveValue::set(Some(self.epoch)), - connection_lost: ActiveValue::set(false), + answering_connection_lost: ActiveValue::set(false), calling_user_id: ActiveValue::set(user_id), calling_connection_id: ActiveValue::set(connection_id.0 as i32), calling_connection_epoch: ActiveValue::set(self.epoch), @@ -1061,7 +1061,7 @@ impl Database { room_participant::ActiveModel { room_id: ActiveValue::set(room_id), user_id: ActiveValue::set(called_user_id), - connection_lost: ActiveValue::set(false), + answering_connection_lost: ActiveValue::set(false), calling_user_id: ActiveValue::set(calling_user_id), calling_connection_id: ActiveValue::set(calling_connection_id.0 as i32), calling_connection_epoch: ActiveValue::set(self.epoch), @@ -1180,13 +1180,13 @@ impl Database { .and( room_participant::Column::AnsweringConnectionId .is_null() - .or(room_participant::Column::ConnectionLost.eq(true)), + .or(room_participant::Column::AnsweringConnectionLost.eq(true)), ), ) .set(room_participant::ActiveModel { answering_connection_id: ActiveValue::set(Some(connection_id.0 as i32)), answering_connection_epoch: ActiveValue::set(Some(self.epoch)), - connection_lost: ActiveValue::set(false), + answering_connection_lost: ActiveValue::set(false), ..Default::default() }) .exec(&*tx) @@ -1387,7 +1387,7 @@ impl Database { let room_id = participant.room_id; room_participant::Entity::update(room_participant::ActiveModel { - connection_lost: ActiveValue::set(true), + answering_connection_lost: ActiveValue::set(true), ..participant.into_active_model() }) .exec(&*tx) diff --git a/crates/collab/src/db/room_participant.rs b/crates/collab/src/db/room_participant.rs index 3ab3fbbdda..c80c10c1ba 100644 --- a/crates/collab/src/db/room_participant.rs +++ b/crates/collab/src/db/room_participant.rs @@ -10,7 +10,7 @@ pub struct Model { pub user_id: UserId, pub answering_connection_id: Option, pub answering_connection_epoch: Option, - pub connection_lost: bool, + pub answering_connection_lost: bool, pub location_kind: Option, pub location_project_id: Option, pub initial_project_id: Option, diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index e1d318fd3e..a799837ad4 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -658,11 +658,12 @@ async fn sign_out( .await .remove_connection(session.connection_id)?; - if let Ok(mut left_projects) = session + if let Some(mut left_projects) = session .db() .await .connection_lost(session.connection_id) .await + .trace_err() { for left_project in mem::take(&mut *left_projects) { project_left(&left_project, &session);