From e742a9039a3fee67649d1062469ff4ac99c7ae8a Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:18:20 +0800 Subject: [PATCH] chore: bump collab version (#807) --- Cargo.lock | 12 +++--- Cargo.toml | 12 +++--- .../src/database/database_collab.rs | 37 +------------------ .../src/document/getting_started.rs | 21 ++++------- src/biz/user/user_init.rs | 2 +- src/biz/workspace/publish_dup.rs | 3 +- tests/workspace/publish.rs | 2 +- 7 files changed, 24 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ea230e8..0fcd85b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "async-trait", @@ -2144,7 +2144,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "bytes", @@ -2183,7 +2183,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2268,7 +2268,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "collab", diff --git a/Cargo.toml b/Cargo.toml index cda39260..34418520 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,12 +287,12 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } [features] history = [] diff --git a/libs/workspace-template/src/database/database_collab.rs b/libs/workspace-template/src/database/database_collab.rs index 083be635..28d0b144 100644 --- a/libs/workspace-template/src/database/database_collab.rs +++ b/libs/workspace-template/src/database/database_collab.rs @@ -1,49 +1,16 @@ use anyhow::Error; -use async_trait::async_trait; -use collab::preclude::Collab; use collab_database::database::{Database, DatabaseContext}; use collab_database::entity::{CreateDatabaseParams, EncodedDatabase}; -use collab_database::error::DatabaseError; -use collab_database::workspace_database::{ - DatabaseCollabPersistenceService, DatabaseCollabService, -}; -use collab_entity::CollabType; -use collab_folder::CollabOrigin; +use collab_database::workspace_database::NoPersistenceDatabaseCollabService; use std::sync::Arc; -use std::vec; - -struct TemplateDatabaseCollabServiceImpl; - -#[async_trait] -impl DatabaseCollabService for TemplateDatabaseCollabServiceImpl { - async fn build_collab( - &self, - object_id: &str, - _object_type: CollabType, - _is_new: bool, - ) -> Result { - Ok(Collab::new_with_origin( - CollabOrigin::Empty, - object_id, - vec![], - false, - )) - } - - fn persistence(&self) -> Option> { - None - } -} pub async fn create_database_collab( - _object_id: String, params: CreateDatabaseParams, ) -> Result { - let collab_service = Arc::new(TemplateDatabaseCollabServiceImpl); + let collab_service = Arc::new(NoPersistenceDatabaseCollabService); let context = DatabaseContext { collab_service, notifier: Default::default(), - is_new: true, }; Database::create_with_view(params, context) .await? diff --git a/libs/workspace-template/src/document/getting_started.rs b/libs/workspace-template/src/document/getting_started.rs index b31b1ce1..23f0c3b9 100644 --- a/libs/workspace-template/src/document/getting_started.rs +++ b/libs/workspace-template/src/document/getting_started.rs @@ -65,13 +65,10 @@ impl GettingStartedTemplate { object_id: String, create_database_params: CreateDatabaseParams, ) -> anyhow::Result> { - let object_id = object_id.clone(); let database_id = create_database_params.database_id.clone(); - let encoded_database = tokio::task::spawn_blocking({ - let object_id = object_id.clone(); let create_database_params = create_database_params.clone(); - move || create_database_collab(object_id, create_database_params) + move || create_database_collab(create_database_params) }) .await? .await?; @@ -84,7 +81,7 @@ impl GettingStartedTemplate { // 1. create the new database collab let database_template_data = TemplateData { template_id: TemplateObjectId::Database { - object_id: object_id.clone(), + object_id, database_id: database_id.clone(), }, collab_type: CollabType::Database, @@ -95,15 +92,11 @@ impl GettingStartedTemplate { let database_row_template_data = encoded_database .encoded_row_collabs - .iter() - .map(|encoded_row_collab| { - let object_id = encoded_row_collab.object_id.clone(); - let data = encoded_row_collab.encoded_collab.clone(); - TemplateData { - template_id: TemplateObjectId::DatabaseRow(object_id.clone()), - collab_type: CollabType::DatabaseRow, - encoded_collab: data, - } + .into_iter() + .map(|encoded_row_collab| TemplateData { + template_id: TemplateObjectId::DatabaseRow(encoded_row_collab.object_id), + collab_type: CollabType::DatabaseRow, + encoded_collab: encoded_row_collab.encoded_collab, }); let mut template_data = vec![database_template_data]; diff --git a/src/biz/user/user_init.rs b/src/biz/user/user_init.rs index 46de113d..a8f83651 100644 --- a/src/biz/user/user_init.rs +++ b/src/biz/user/user_init.rs @@ -158,7 +158,7 @@ async fn create_workspace_database_collab( let collab_type = CollabType::WorkspaceDatabase; let mut collab = Collab::new_with_origin(CollabOrigin::Empty, object_id, vec![], false); { - let workspace_database_body = WorkspaceDatabaseBody::new(&mut collab); + let workspace_database_body = WorkspaceDatabaseBody::create(&mut collab); let mut txn = collab.context.transact_mut(); for (object_id, database_id) in initial_database_records { workspace_database_body.add_database(&mut txn, &database_id, vec![object_id]); diff --git a/src/biz/workspace/publish_dup.rs b/src/biz/workspace/publish_dup.rs index 3e0a12dc..74dd570a 100644 --- a/src/biz/workspace/publish_dup.rs +++ b/src/biz/workspace/publish_dup.rs @@ -177,8 +177,7 @@ impl PublishCollabDuplicator { collab_from_doc_state(ws_database_ec.doc_state.to_vec(), &ws_db_oid)? }; - let ws_db_body = WorkspaceDatabaseBody::new(&mut ws_db_collab); - + let ws_db_body = WorkspaceDatabaseBody::open(&mut ws_db_collab); let (ws_db_updates, updated_ws_w_db_collab) = tokio::task::spawn_blocking(move || { let ws_db_updates = { let mut txn_wrapper = ws_db_collab.transact_mut(); diff --git a/tests/workspace/publish.rs b/tests/workspace/publish.rs index 710706a7..21d7d487 100644 --- a/tests/workspace/publish.rs +++ b/tests/workspace/publish.rs @@ -940,7 +940,7 @@ async fn duplicate_to_workspace_doc_inline_database() { let mut ws_db_collab = client_2 .get_workspace_database_collab(&workspace_id_2) .await; - let ws_db_body = WorkspaceDatabaseBody::new(&mut ws_db_collab); + let ws_db_body = WorkspaceDatabaseBody::open(&mut ws_db_collab); let txn = ws_db_collab.transact(); let dup_grid1_db_id = ws_db_body .get_all_database_meta(&txn)