chore: bump collab version (#807)

This commit is contained in:
Nathan.fooo 2024-09-10 11:18:20 +08:00 committed by GitHub
parent cd3cd717bf
commit e742a9039a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 65 deletions

12
Cargo.lock generated
View File

@ -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",

View File

@ -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 = []

View File

@ -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<Collab, DatabaseError> {
Ok(Collab::new_with_origin(
CollabOrigin::Empty,
object_id,
vec![],
false,
))
}
fn persistence(&self) -> Option<Arc<dyn DatabaseCollabPersistenceService>> {
None
}
}
pub async fn create_database_collab(
_object_id: String,
params: CreateDatabaseParams,
) -> Result<EncodedDatabase, Error> {
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?

View File

@ -65,13 +65,10 @@ impl GettingStartedTemplate {
object_id: String,
create_database_params: CreateDatabaseParams,
) -> anyhow::Result<Vec<TemplateData>> {
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];

View File

@ -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]);

View File

@ -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();

View File

@ -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)