mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-08 18:35:06 +03:00
simplify server implementation
This commit is contained in:
parent
9a1dd0c6bc
commit
129f2890c5
@ -2277,13 +2277,6 @@ async fn join_channel(
|
||||
let joined_room = {
|
||||
let db = session.db().await;
|
||||
|
||||
if db
|
||||
.is_current_room_different_channel(session.user_id, channel_id)
|
||||
.await?
|
||||
{
|
||||
leave_room_for_session_with_guard(&session, &db).await?;
|
||||
}
|
||||
|
||||
let room_id = db.room_id_for_channel(channel_id).await?;
|
||||
|
||||
let joined_room = db
|
||||
@ -2539,14 +2532,7 @@ fn channel_updated(
|
||||
|
||||
async fn update_user_contacts(user_id: UserId, session: &Session) -> Result<()> {
|
||||
let db = session.db().await;
|
||||
update_user_contacts_with_guard(user_id, session, &db).await
|
||||
}
|
||||
|
||||
async fn update_user_contacts_with_guard(
|
||||
user_id: UserId,
|
||||
session: &Session,
|
||||
db: &DbHandle,
|
||||
) -> Result<()> {
|
||||
let contacts = db.get_contacts(user_id).await?;
|
||||
let busy = db.is_user_busy(user_id).await?;
|
||||
|
||||
@ -2580,11 +2566,6 @@ async fn update_user_contacts_with_guard(
|
||||
}
|
||||
|
||||
async fn leave_room_for_session(session: &Session) -> Result<()> {
|
||||
let db = session.db().await;
|
||||
leave_room_for_session_with_guard(session, &db).await
|
||||
}
|
||||
|
||||
async fn leave_room_for_session_with_guard(session: &Session, db: &DbHandle) -> Result<()> {
|
||||
let mut contacts_to_update = HashSet::default();
|
||||
|
||||
let room_id;
|
||||
@ -2595,7 +2576,7 @@ async fn leave_room_for_session_with_guard(session: &Session, db: &DbHandle) ->
|
||||
let channel_members;
|
||||
let channel_id;
|
||||
|
||||
if let Some(mut left_room) = db.leave_room(session.connection_id).await? {
|
||||
if let Some(mut left_room) = session.db().await.leave_room(session.connection_id).await? {
|
||||
contacts_to_update.insert(session.user_id);
|
||||
|
||||
for project in left_room.left_projects.values() {
|
||||
@ -2645,7 +2626,7 @@ async fn leave_room_for_session_with_guard(session: &Session, db: &DbHandle) ->
|
||||
}
|
||||
|
||||
for contact_user_id in contacts_to_update {
|
||||
update_user_contacts_with_guard(contact_user_id, &session, db).await?;
|
||||
update_user_contacts(contact_user_id, &session).await?;
|
||||
}
|
||||
|
||||
if let Some(live_kit) = session.live_kit_client.as_ref() {
|
||||
|
Loading…
Reference in New Issue
Block a user