mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
[rust]: fix potential get cur workspace fail
This commit is contained in:
parent
635f6b8607
commit
820fb1f61f
2 changed files with 20 additions and 6 deletions
|
@ -122,8 +122,9 @@ async fn _listen_user_status(
|
||||||
UserStatus::Expired { .. } => {
|
UserStatus::Expired { .. } => {
|
||||||
workspace_controller.user_session_expired();
|
workspace_controller.user_session_expired();
|
||||||
},
|
},
|
||||||
UserStatus::SignUp { profile } => {
|
UserStatus::SignUp { profile, ret } => {
|
||||||
let _ = workspace_controller.user_did_sign_up(&profile.token).await?;
|
let _ = workspace_controller.user_did_sign_up(&profile.token).await?;
|
||||||
|
let _ = ret.send(());
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Ok::<(), WorkspaceError>(())
|
Ok::<(), WorkspaceError>(())
|
||||||
|
|
|
@ -23,14 +23,23 @@ use flowy_ws::{WsController, WsMessageHandler, WsState};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::{broadcast, mpsc};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum UserStatus {
|
pub enum UserStatus {
|
||||||
Login { token: String },
|
Login {
|
||||||
Logout { token: String },
|
token: String,
|
||||||
Expired { token: String },
|
},
|
||||||
SignUp { profile: UserProfile },
|
Logout {
|
||||||
|
token: String,
|
||||||
|
},
|
||||||
|
Expired {
|
||||||
|
token: String,
|
||||||
|
},
|
||||||
|
SignUp {
|
||||||
|
profile: UserProfile,
|
||||||
|
ret: mpsc::Sender<()>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UserSessionConfig {
|
pub struct UserSessionConfig {
|
||||||
|
@ -130,9 +139,13 @@ impl UserSession {
|
||||||
let _ = self.set_session(Some(session))?;
|
let _ = self.set_session(Some(session))?;
|
||||||
let user_table = self.save_user(resp.into()).await?;
|
let user_table = self.save_user(resp.into()).await?;
|
||||||
let user_profile: UserProfile = user_table.into();
|
let user_profile: UserProfile = user_table.into();
|
||||||
|
let (ret, mut tx) = mpsc::channel(1);
|
||||||
let _ = self.status_notifier.send(UserStatus::SignUp {
|
let _ = self.status_notifier.send(UserStatus::SignUp {
|
||||||
profile: user_profile.clone(),
|
profile: user_profile.clone(),
|
||||||
|
ret,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = tx.recv().await;
|
||||||
Ok(user_profile)
|
Ok(user_profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue