mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: fix open workspace (#5092)
* chore: fix open workspace * chore: fix open workspace
This commit is contained in:
parent
31798959c7
commit
5c96a2c5cb
@ -7,6 +7,7 @@ use collab_integrate::CollabKVDB;
|
|||||||
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
|
||||||
use flowy_sqlite::kv::StorePreferences;
|
use flowy_sqlite::kv::StorePreferences;
|
||||||
use flowy_sqlite::DBConnection;
|
use flowy_sqlite::DBConnection;
|
||||||
|
use flowy_user_pub::entities::UserWorkspace;
|
||||||
use flowy_user_pub::session::Session;
|
use flowy_user_pub::session::Session;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
@ -104,6 +105,12 @@ impl AuthenticateUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_user_workspace(&self, user_workspace: UserWorkspace) -> FlowyResult<()> {
|
||||||
|
let mut session = self.get_session()?;
|
||||||
|
session.user_workspace = user_workspace;
|
||||||
|
self.set_session(Some(session))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_session(&self) -> FlowyResult<Session> {
|
pub fn get_session(&self) -> FlowyResult<Session> {
|
||||||
if let Some(session) = (self.session.read()).clone() {
|
if let Some(session) = (self.session.read()).clone() {
|
||||||
return Ok(session);
|
return Ok(session);
|
||||||
|
@ -134,23 +134,25 @@ impl UserManager {
|
|||||||
#[instrument(skip(self), err)]
|
#[instrument(skip(self), err)]
|
||||||
pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
|
pub async fn open_workspace(&self, workspace_id: &str) -> FlowyResult<()> {
|
||||||
let uid = self.user_id()?;
|
let uid = self.user_id()?;
|
||||||
let _ = self
|
let user_workspace = self
|
||||||
.cloud_services
|
.cloud_services
|
||||||
.get_user_service()?
|
.get_user_service()?
|
||||||
.open_workspace(workspace_id)
|
.open_workspace(workspace_id)
|
||||||
.await;
|
.await?;
|
||||||
|
|
||||||
if let Some(user_workspace) = self.get_user_workspace(uid, workspace_id) {
|
self
|
||||||
if let Err(err) = self
|
.authenticate_user
|
||||||
.user_status_callback
|
.set_user_workspace(user_workspace.clone())?;
|
||||||
.read()
|
if let Err(err) = self
|
||||||
.await
|
.user_status_callback
|
||||||
.open_workspace(uid, &user_workspace)
|
.read()
|
||||||
.await
|
.await
|
||||||
{
|
.open_workspace(uid, &user_workspace)
|
||||||
error!("Open workspace failed: {:?}", err);
|
.await
|
||||||
}
|
{
|
||||||
|
error!("Open workspace failed: {:?}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user