diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock index 2ce43d14f2..c285dfc585 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.lock +++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-trait", @@ -1018,7 +1018,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -1038,7 +1038,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "bytes", @@ -1057,7 +1057,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-stream", @@ -1180,7 +1180,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index c8488232b5..dfb3e2fa09 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock index cbf0e3167b..459c0d8213 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.lock +++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -972,7 +972,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-trait", @@ -1001,7 +1001,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -1021,7 +1021,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "bytes", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -1083,7 +1083,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-stream", @@ -1163,7 +1163,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml index 71a373a38a..eb0c3d72fa 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.toml +++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 48121e8896..be6b976864 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -825,7 +825,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -850,7 +850,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-trait", @@ -879,7 +879,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -899,7 +899,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "bytes", @@ -918,7 +918,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "arc-swap", @@ -961,7 +961,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "async-stream", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=97163517303bb0ed468992a4511aac6eb8775a4d#97163517303bb0ed468992a4511aac6eb8775a4d" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=6f98f054a8306a8791b65bf1825091ab3fe60166#6f98f054a8306a8791b65bf1825091ab3fe60166" dependencies = [ "anyhow", "collab", diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index f88d143116..a36439e746 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120 # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "97163517303bb0ed468992a4511aac6eb8775a4d" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "6f98f054a8306a8791b65bf1825091ab3fe60166" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/collab-integrate/src/collab_builder.rs b/frontend/rust-lib/collab-integrate/src/collab_builder.rs index da99addf0e..e20ab74a31 100644 --- a/frontend/rust-lib/collab-integrate/src/collab_builder.rs +++ b/frontend/rust-lib/collab-integrate/src/collab_builder.rs @@ -158,9 +158,10 @@ impl AppFlowyCollabBuilder { ) -> Result>, Error> { let expected_collab_type = CollabType::Document; assert_eq!(object.collab_type, expected_collab_type); - let collab = self.build_collab(&object, &collab_db, data_source)?; - let document = Document::open_with(collab, data)?; + let mut collab = self.build_collab(&object, &collab_db, data_source)?; + collab.enable_undo_redo(); + let document = Document::open_with(collab, data)?; self.flush_collab_if_not_exist( object.uid, &object.object_id, @@ -296,39 +297,43 @@ impl AppFlowyCollabBuilder { where T: BorrowMut + Send + Sync + 'static, { + if !build_config.sync_enable { + return Ok(collab); + } + let mut write_collab = collab.try_write()?; if !write_collab.borrow().get_state().is_uninitialized() { warn!("{} is already initialized", object); drop(write_collab); return Ok(collab); } - trace!("🚀finalize collab:{}", object); - if build_config.sync_enable { - let plugin_provider = self.plugin_provider.load_full(); - let provider_type = plugin_provider.provider_type(); - let span = - tracing::span!(tracing::Level::TRACE, "collab_builder", object_id = %object.object_id); - let _enter = span.enter(); - match provider_type { - CollabPluginProviderType::AppFlowyCloud => { - let local_collab = Arc::downgrade(&collab); - let plugins = plugin_provider.get_plugins(CollabPluginProviderContext::AppFlowyCloud { - uid: object.uid, - collab_object: object, - local_collab, - }); - // at the moment when we get the lock, the collab object is not yet exposed outside - for plugin in plugins { - write_collab.borrow().add_plugin(plugin); - } - }, - CollabPluginProviderType::Local => {}, - } + trace!("🚀finalize collab:{}", object); + let plugin_provider = self.plugin_provider.load_full(); + let provider_type = plugin_provider.provider_type(); + let span = + tracing::span!(tracing::Level::TRACE, "collab_builder", object_id = %object.object_id); + let _enter = span.enter(); + match provider_type { + CollabPluginProviderType::AppFlowyCloud => { + let local_collab = Arc::downgrade(&collab); + let plugins = plugin_provider.get_plugins(CollabPluginProviderContext::AppFlowyCloud { + uid: object.uid, + collab_object: object, + local_collab, + }); + + // at the moment when we get the lock, the collab object is not yet exposed outside + for plugin in plugins { + write_collab.borrow().add_plugin(plugin); + } + }, + CollabPluginProviderType::Local => {}, } (*write_collab).borrow_mut().initialize(); drop(write_collab); + Ok(collab) } @@ -406,8 +411,18 @@ impl CollabPersistence for KVDBCollabPersistenceImpl { if rocksdb_read.is_exist(self.uid, &object_id) { let mut txn = collab.transact_mut(); - if let Err(err) = rocksdb_read.load_doc_with_txn(self.uid, &object_id, &mut txn) { - error!("🔴 load doc:{} failed: {}", object_id, err); + match rocksdb_read.load_doc_with_txn(self.uid, &object_id, &mut txn) { + Ok(update_count) => { + trace!( + "did load collab:{}-{} from disk, update_count:{}", + self.uid, + object_id, + update_count + ); + }, + Err(err) => { + error!("🔴 load doc:{} failed: {}", object_id, err); + }, } drop(rocksdb_read); txn.commit(); diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index bd2e300f31..51626126bb 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -19,7 +19,7 @@ use collab_database::workspace_database::{ use collab_entity::{CollabType, EncodedCollab}; use collab_plugins::local_storage::kv::KVTransactionDB; use tokio::sync::{Mutex, RwLock}; -use tracing::{event, instrument, trace}; +use tracing::{error, event, instrument, trace}; use collab_integrate::collab_builder::{ AppFlowyCollabBuilder, CollabBuilderConfig, KVDBCollabPersistenceImpl, @@ -688,6 +688,7 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl { ) -> Result, DatabaseError> { let workspace_id = self.user.workspace_id().unwrap(); let object_id = object_id.to_string(); + trace!("[Database]: fetch {}:{} from remote", object_id, object_ty); let weak_cloud_service = Arc::downgrade(&self.cloud_service); match weak_cloud_service.upgrade() { @@ -766,11 +767,31 @@ pub struct DatabasePersistenceImpl { impl DatabaseCollabPersistenceService for DatabasePersistenceImpl { fn load_collab(&self, uid: i64, collab: &mut Collab) { if let Ok(Some(collab_db)) = self.user.collab_db(uid).map(|weak| weak.upgrade()) { - trace!("[Database]: load collab:{}", collab.object_id()); let object_id = collab.object_id().to_string(); - let mut txn = collab.transact_mut(); let db_read = collab_db.read_txn(); - let _ = db_read.load_doc_with_txn(uid, &object_id, &mut txn); + if !db_read.is_exist(uid, &object_id) { + trace!( + "[Database]: collab:{} not exist in local storage", + object_id + ); + } + + trace!("[Database]: start loading collab:{}", object_id); + let mut txn = collab.transact_mut(); + match db_read.load_doc_with_txn(uid, &object_id, &mut txn) { + Ok(update_count) => { + trace!( + "[Database]: did load collab:{}, update_count:{}", + object_id, + update_count + ); + }, + Err(err) => { + if !err.is_record_not_found() { + error!("[Database]: load collab:{} failed:{}", object_id, err); + } + }, + } } }