Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

[rust]: fix potential get cur workspace fail

appflowy820fb1f61f49
diff --git a/rust-lib/flowy-sdk/src/lib.rs b/rust-lib/flowy-sdk/src/lib.rs
index 9caced7d2d..1ca0f121ce 100644
--- a/rust-lib/flowy-sdk/src/lib.rs
+++ b/rust-lib/flowy-sdk/src/lib.rs
@@ -122,8 +122,9 @@ async fn _listen_user_status(
UserStatus::Expired { .. } => {
workspace_controller.user_session_expired();
},
- UserStatus::SignUp { profile } => {
+ UserStatus::SignUp { profile, ret } => {
let _ = workspace_controller.user_did_sign_up(&profile.token).await?;
+ let _ = ret.send(());
},
}
Ok::<(), WorkspaceError>(())
diff --git a/rust-lib/flowy-user/src/services/user/user_session.rs b/rust-lib/flowy-user/src/services/user/user_session.rs
index f4e4bbb42a..5dc13abf09 100644
--- a/rust-lib/flowy-user/src/services/user/user_session.rs
+++ b/rust-lib/flowy-user/src/services/user/user_session.rs
@@ -23,14 +23,23 @@ use flowy_ws::{WsController, WsMessageHandler, WsState};
use parking_lot::RwLock;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
-use tokio::sync::broadcast;
+use tokio::sync::{broadcast, mpsc};
#[derive(Clone)]
pub enum UserStatus {
- Login { token: String },
- Logout { token: String },
- Expired { token: String },
- SignUp { profile: UserProfile },
+ Login {
+ token: String,
+ },
+ Logout {
+ token: String,
+ },
+ Expired {
+ token: String,
+ },
+ SignUp {
+ profile: UserProfile,
+ ret: mpsc::Sender<()>,
+ },
}
pub struct UserSessionConfig {
@@ -130,9 +139,13 @@ impl UserSession {
let _ = self.set_session(Some(session))?;
let user_table = self.save_user(resp.into()).await?;
let user_profile: UserProfile = user_table.into();
+ let (ret, mut tx) = mpsc::channel(1);
let _ = self.status_notifier.send(UserStatus::SignUp {
profile: user_profile.clone(),
+ ret,
});
+
+ let _ = tx.recv().await;
Ok(user_profile)
}
}