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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: workspace id not match (#5454)
Nathan.fooo9c9168ac5b4c
diff --git a/frontend/rust-lib/flowy-document/src/event_handler.rs b/frontend/rust-lib/flowy-document/src/event_handler.rsindex c87ed6ec79..029405c6cc 100644--- a/frontend/rust-lib/flowy-document/src/event_handler.rs+++ b/frontend/rust-lib/flowy-document/src/event_handler.rs@@ -56,6 +56,8 @@ pub(crate) async fn open_document_handler(let manager = upgrade_document(manager)?;let params: OpenDocumentParams = data.into_inner().try_into()?;let doc_id = params.document_id;+ manager.open_document(&doc_id).await?;+let document = manager.get_document(&doc_id).await?;let document_data = document.lock().get_document_data()?;data_result_ok(DocumentDataPB::from(document_data))diff --git a/frontend/rust-lib/flowy-document/src/manager.rs b/frontend/rust-lib/flowy-document/src/manager.rsindex 06639257d4..fb3b203b4e 100644--- a/frontend/rust-lib/flowy-document/src/manager.rs+++ b/frontend/rust-lib/flowy-document/src/manager.rs@@ -77,7 +77,9 @@ impl DocumentManager {}pub async fn initialize(&self, _uid: i64) -> FlowyResult<()> {+ trace!("initialize document manager");self.documents.clear();+ self.removing_documents.clear();Ok(())}@@ -130,9 +132,6 @@ impl DocumentManager {}}- /// Returns Document for given object id- /// If the document does not exist in local disk, try get the doc state from the cloud.- /// If the document exists, open the document and cache it#[tracing::instrument(level = "info", skip(self), err)]pub async fn get_document(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> {if let Some(doc) = self.documents.get(doc_id).map(|item| item.value().clone()) {@@ -142,6 +141,17 @@ impl DocumentManager {if let Some(doc) = self.restore_document_from_removing(doc_id) {return Ok(doc);}+ return Err(FlowyError::internal().with_context("Call open document first"));+ }++ /// Returns Document for given object id+ /// If the document does not exist in local disk, try get the doc state from the cloud.+ /// If the document exists, open the document and cache it+ #[tracing::instrument(level = "info", skip(self), err)]+ async fn create_document_instance(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> {+ if let Some(doc) = self.documents.get(doc_id).map(|item| item.value().clone()) {+ return Ok(doc);+ }let mut doc_state = DataSource::Disk;// If the document does not exist in local disk, try get the doc state from the cloud. This happens@@ -164,7 +174,12 @@ impl DocumentManager {}let uid = self.user_service.user_id()?;- event!(tracing::Level::DEBUG, "Initialize document: {}", doc_id);+ event!(+ tracing::Level::DEBUG,+ "Initialize document: {}, workspace_id: {:?}",+ doc_id,+ self.user_service.workspace_id()+ );let collab = self.collab_for_document(uid, doc_id, doc_state, true).await?;@@ -209,6 +224,8 @@ impl DocumentManager {if let Some(mutex_document) = self.restore_document_from_removing(doc_id) {mutex_document.start_init_sync();}++ let _ = self.create_document_instance(doc_id).await?;Ok(())}@@ -247,6 +264,7 @@ impl DocumentManager {Ok(())}+ #[instrument(level = "debug", skip_all, err)]pub async fn set_document_awareness_local_state(&self,doc_id: &str,