chore: drop old user awarenss when open workspace (#5271)

This commit is contained in:
Nathan.fooo 2024-05-06 18:12:56 +08:00 committed by GitHub
parent 560529f7d9
commit 3bdc8c222c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -7,7 +7,7 @@ use collab_entity::reminder::Reminder;
use collab_entity::CollabType;
use collab_integrate::collab_builder::{AppFlowyCollabBuilder, CollabBuilderConfig};
use collab_user::core::{MutexUserAwareness, UserAwareness};
use tracing::{error, info, instrument, trace};
use tracing::{debug, error, info, instrument, trace};
use collab_integrate::CollabKVDB;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
@ -127,6 +127,12 @@ impl UserManager {
}
self.is_loading_awareness.store(true, Ordering::SeqCst);
if let Some(old_user_awareness) = self.user_awareness.lock().await.take() {
debug!("Closing old user awareness");
old_user_awareness.lock().close();
drop(old_user_awareness);
}
let object_id =
user_awareness_object_id(&session.user_uuid, &session.user_workspace.id).to_string();
trace!("Initializing user awareness {}", object_id);

View File

@ -166,6 +166,13 @@ impl UserManager {
.authenticate_user
.set_user_workspace(user_workspace.clone())?;
if let Err(err) = self.try_initial_user_awareness(&self.get_session()?).await {
error!(
"Failed to initialize user awareness when opening workspace: {:?}",
err
);
}
let uid = self.user_id()?;
if let Err(err) = self
.user_status_callback