mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: remove lru (#5008)
* chore: remove lru * chore: update logs * chore: clippy
This commit is contained in:
@ -23,7 +23,7 @@ where
|
||||
object_id: &str,
|
||||
collab_type: CollabType,
|
||||
workspace_id: &str,
|
||||
) -> FutureResult<Vec<u8>, Error> {
|
||||
) -> FutureResult<Option<Vec<u8>>, Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let object_id = object_id.to_string();
|
||||
let try_get_client = self.0.try_get_client();
|
||||
@ -36,10 +36,10 @@ where
|
||||
},
|
||||
};
|
||||
match try_get_client?.get_collab(params).await {
|
||||
Ok(data) => Ok(data.doc_state.to_vec()),
|
||||
Ok(data) => Ok(Some(data.doc_state.to_vec())),
|
||||
Err(err) => {
|
||||
if err.code == RecordNotFound {
|
||||
Ok(vec![])
|
||||
Ok(None)
|
||||
} else {
|
||||
Err(Error::new(err))
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
use anyhow::Error;
|
||||
use collab::preclude::Collab;
|
||||
use collab_entity::define::{DATABASE, DATABASE_ROW_DATA, WORKSPACE_DATABASES};
|
||||
use collab_entity::CollabType;
|
||||
use yrs::{Any, MapPrelim};
|
||||
|
||||
use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot};
|
||||
use lib_infra::future::FutureResult;
|
||||
@ -9,11 +12,40 @@ pub(crate) struct LocalServerDatabaseCloudServiceImpl();
|
||||
impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl {
|
||||
fn get_database_object_doc_state(
|
||||
&self,
|
||||
_object_id: &str,
|
||||
_collab_type: CollabType,
|
||||
object_id: &str,
|
||||
collab_type: CollabType,
|
||||
_workspace_id: &str,
|
||||
) -> FutureResult<Vec<u8>, Error> {
|
||||
FutureResult::new(async move { Ok(vec![]) })
|
||||
) -> FutureResult<Option<Vec<u8>>, Error> {
|
||||
let object_id = object_id.to_string();
|
||||
// create the minimal required data for the given collab type
|
||||
FutureResult::new(async move {
|
||||
let data = match collab_type {
|
||||
CollabType::Database => {
|
||||
let collab = Collab::new(1, object_id, collab_type, vec![], false);
|
||||
collab.with_origin_transact_mut(|txn| {
|
||||
collab.insert_map_with_txn(txn, DATABASE);
|
||||
});
|
||||
collab.encode_collab_v1().doc_state.to_vec()
|
||||
},
|
||||
CollabType::WorkspaceDatabase => {
|
||||
let collab = Collab::new(1, object_id, collab_type, vec![], false);
|
||||
collab.with_origin_transact_mut(|txn| {
|
||||
collab.create_array_with_txn::<MapPrelim<Any>>(txn, WORKSPACE_DATABASES, vec![]);
|
||||
});
|
||||
collab.encode_collab_v1().doc_state.to_vec()
|
||||
},
|
||||
CollabType::DatabaseRow => {
|
||||
let collab = Collab::new(1, object_id, collab_type, vec![], false);
|
||||
collab.with_origin_transact_mut(|txn| {
|
||||
collab.insert_map_with_txn(txn, DATABASE_ROW_DATA);
|
||||
});
|
||||
collab.encode_collab_v1().doc_state.to_vec()
|
||||
},
|
||||
_ => vec![],
|
||||
};
|
||||
|
||||
Ok(Some(data))
|
||||
})
|
||||
}
|
||||
|
||||
fn batch_get_database_object_doc_state(
|
||||
|
@ -30,7 +30,7 @@ where
|
||||
object_id: &str,
|
||||
collab_type: CollabType,
|
||||
_workspace_id: &str,
|
||||
) -> FutureResult<Vec<u8>, Error> {
|
||||
) -> FutureResult<Option<Vec<u8>>, Error> {
|
||||
let try_get_postgrest = self.server.try_get_weak_postgrest();
|
||||
let object_id = object_id.to_string();
|
||||
let (tx, rx) = channel();
|
||||
@ -41,7 +41,7 @@ where
|
||||
let updates = FetchObjectUpdateAction::new(object_id.to_string(), collab_type, postgrest)
|
||||
.run_with_fix_interval(5, 10)
|
||||
.await?;
|
||||
Ok(updates)
|
||||
Ok(Some(updates))
|
||||
}
|
||||
.await,
|
||||
)
|
||||
|
@ -284,7 +284,7 @@ pub async fn batch_get_updates_from_server(
|
||||
match parser_updates_form_json(record.clone(), &postgrest.secret()) {
|
||||
Ok(items) => {
|
||||
if items.is_empty() {
|
||||
updates_by_oid.insert(oid.to_string(), DocStateSource::FromDocState(vec![]));
|
||||
updates_by_oid.insert(oid.to_string(), DocStateSource::FromDisk);
|
||||
} else {
|
||||
let updates = items
|
||||
.iter()
|
||||
|
Reference in New Issue
Block a user