mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: rename struct
This commit is contained in:
parent
60b80005ac
commit
8706b81ac0
@ -4,7 +4,7 @@ use crate::{
|
||||
errors::FlowyResult,
|
||||
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
|
||||
services::{
|
||||
folder_editor::ClientFolderEditor, persistence::FolderPersistence, set_current_workspace, AppController,
|
||||
folder_editor::FolderEditor, persistence::FolderPersistence, set_current_workspace, AppController,
|
||||
TrashController, ViewController, WorkspaceController,
|
||||
},
|
||||
};
|
||||
@ -61,7 +61,7 @@ pub struct FolderManager {
|
||||
pub(crate) view_controller: Arc<ViewController>,
|
||||
pub(crate) trash_controller: Arc<TrashController>,
|
||||
web_socket: Arc<dyn RevisionWebSocket>,
|
||||
folder_editor: Arc<TokioRwLock<Option<Arc<ClientFolderEditor>>>>,
|
||||
folder_editor: Arc<TokioRwLock<Option<Arc<FolderEditor>>>>,
|
||||
data_processors: ViewDataProcessorMap,
|
||||
}
|
||||
|
||||
@ -166,8 +166,7 @@ impl FolderManager {
|
||||
let rev_persistence = Arc::new(RevisionPersistence::new(user_id, folder_id.as_ref(), disk_cache));
|
||||
let rev_manager = RevisionManager::new(user_id, folder_id.as_ref(), rev_persistence);
|
||||
|
||||
let folder_editor =
|
||||
ClientFolderEditor::new(user_id, &folder_id, token, rev_manager, self.web_socket.clone()).await?;
|
||||
let folder_editor = FolderEditor::new(user_id, &folder_id, token, rev_manager, self.web_socket.clone()).await?;
|
||||
*self.folder_editor.write().await = Some(Arc::new(folder_editor));
|
||||
|
||||
let _ = self.app_controller.initialize()?;
|
||||
@ -228,7 +227,7 @@ impl DefaultFolderBuilder {
|
||||
|
||||
#[cfg(feature = "flowy_unit_test")]
|
||||
impl FolderManager {
|
||||
pub async fn folder_editor(&self) -> Arc<ClientFolderEditor> {
|
||||
pub async fn folder_editor(&self) -> Arc<FolderEditor> {
|
||||
self.folder_editor.read().await.clone().unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub(crate) async fn update_app_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, app_controller, view_controller))]
|
||||
#[tracing::instrument(level = "trace", skip(data, app_controller, view_controller))]
|
||||
pub(crate) async fn read_app_handler(
|
||||
data: Data<AppId>,
|
||||
app_controller: AppData<Arc<AppController>>,
|
||||
|
@ -17,7 +17,7 @@ use lib_ot::core::PlainTextAttributes;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct ClientFolderEditor {
|
||||
pub struct FolderEditor {
|
||||
user_id: String,
|
||||
#[allow(dead_code)]
|
||||
pub(crate) folder_id: FolderId,
|
||||
@ -27,7 +27,7 @@ pub struct ClientFolderEditor {
|
||||
ws_manager: Arc<flowy_revision::RevisionWebSocketManager>,
|
||||
}
|
||||
|
||||
impl ClientFolderEditor {
|
||||
impl FolderEditor {
|
||||
#[allow(unused_variables)]
|
||||
pub async fn new(
|
||||
user_id: &str,
|
||||
@ -129,7 +129,7 @@ impl RevisionCloudService for FolderRevisionCloudService {
|
||||
}
|
||||
|
||||
#[cfg(feature = "flowy_unit_test")]
|
||||
impl ClientFolderEditor {
|
||||
impl FolderEditor {
|
||||
pub fn rev_manager(&self) -> Arc<RevisionManager> {
|
||||
self.rev_manager.clone()
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ mod version_2;
|
||||
use crate::{
|
||||
event_map::WorkspaceDatabase,
|
||||
manager::FolderId,
|
||||
services::{folder_editor::ClientFolderEditor, persistence::migration::FolderMigration},
|
||||
services::{folder_editor::FolderEditor, persistence::migration::FolderMigration},
|
||||
};
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
@ -50,14 +50,11 @@ pub trait FolderPersistenceTransaction {
|
||||
|
||||
pub struct FolderPersistence {
|
||||
database: Arc<dyn WorkspaceDatabase>,
|
||||
folder_editor: Arc<RwLock<Option<Arc<ClientFolderEditor>>>>,
|
||||
folder_editor: Arc<RwLock<Option<Arc<FolderEditor>>>>,
|
||||
}
|
||||
|
||||
impl FolderPersistence {
|
||||
pub fn new(
|
||||
database: Arc<dyn WorkspaceDatabase>,
|
||||
folder_editor: Arc<RwLock<Option<Arc<ClientFolderEditor>>>>,
|
||||
) -> Self {
|
||||
pub fn new(database: Arc<dyn WorkspaceDatabase>, folder_editor: Arc<RwLock<Option<Arc<FolderEditor>>>>) -> Self {
|
||||
Self {
|
||||
database,
|
||||
folder_editor,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::services::{
|
||||
folder_editor::ClientFolderEditor,
|
||||
folder_editor::FolderEditor,
|
||||
persistence::{AppChangeset, FolderPersistenceTransaction, ViewChangeset, WorkspaceChangeset},
|
||||
};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
@ -11,7 +11,7 @@ use flowy_folder_data_model::entities::{
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
impl FolderPersistenceTransaction for ClientFolderEditor {
|
||||
impl FolderPersistenceTransaction for FolderEditor {
|
||||
fn create_workspace(&self, _user_id: &str, workspace: Workspace) -> FlowyResult<()> {
|
||||
if let Some(change) = self.folder.write().create_workspace(workspace)? {
|
||||
let _ = self.apply_change(change)?;
|
||||
|
@ -129,7 +129,7 @@ impl ViewController {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub(crate) fn set_latest_view(&self, view_id: &str) -> Result<(), FlowyError> {
|
||||
KV::set_str(LATEST_VIEW_ID, view_id.to_owned());
|
||||
Ok(())
|
||||
@ -193,7 +193,7 @@ impl ViewController {
|
||||
}
|
||||
|
||||
// belong_to_id will be the app_id or view_id.
|
||||
#[tracing::instrument(level = "debug", skip(self), err)]
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub(crate) async fn read_views_belong_to(&self, belong_to_id: &str) -> Result<RepeatedView, FlowyError> {
|
||||
self.persistence
|
||||
.begin_transaction(|transaction| {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use flowy_folder::event_map::FolderEvent::*;
|
||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::ClientFolderEditor};
|
||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||
use flowy_folder_data_model::entities::view::{RepeatedViewId, ViewId};
|
||||
use flowy_folder_data_model::entities::workspace::WorkspaceId;
|
||||
use flowy_folder_data_model::entities::{
|
||||
@ -125,7 +125,7 @@ impl FolderTest {
|
||||
|
||||
pub async fn run_script(&mut self, script: FolderScript) {
|
||||
let sdk = &self.sdk;
|
||||
let folder_editor: Arc<ClientFolderEditor> = sdk.folder_manager.folder_editor().await;
|
||||
let folder_editor: Arc<FolderEditor> = sdk.folder_manager.folder_editor().await;
|
||||
let rev_manager = folder_editor.rev_manager();
|
||||
let cache = rev_manager.revision_cache().await;
|
||||
|
||||
|
@ -7,7 +7,7 @@ use flowy_grid_data_model::entities::*;
|
||||
use lib_dispatch::prelude::{data_result, AppData, Data, DataResult};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn get_grid_data_handler(
|
||||
data: Data<GridId>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -34,7 +34,7 @@ pub(crate) async fn get_grid_blocks_handler(
|
||||
data_result(repeated_grid_block)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn get_fields_handler(
|
||||
data: Data<QueryFieldPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -47,7 +47,7 @@ pub(crate) async fn get_fields_handler(
|
||||
data_result(repeated_field)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn update_field_handler(
|
||||
data: Data<FieldChangesetPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -58,7 +58,7 @@ pub(crate) async fn update_field_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn insert_field_handler(
|
||||
data: Data<InsertFieldPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -69,7 +69,7 @@ pub(crate) async fn insert_field_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn update_field_type_option_handler(
|
||||
data: Data<UpdateFieldTypeOptionPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -82,7 +82,7 @@ pub(crate) async fn update_field_type_option_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn delete_field_handler(
|
||||
data: Data<FieldIdentifierPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -93,7 +93,7 @@ pub(crate) async fn delete_field_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn switch_to_field_handler(
|
||||
data: Data<EditFieldPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -120,7 +120,7 @@ pub(crate) async fn switch_to_field_handler(
|
||||
data_result(data)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn duplicate_field_handler(
|
||||
data: Data<FieldIdentifierPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -132,7 +132,7 @@ pub(crate) async fn duplicate_field_handler(
|
||||
}
|
||||
|
||||
/// Return the FieldTypeOptionData if the Field exists otherwise return record not found error.
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn get_field_type_option_data_handler(
|
||||
data: Data<EditFieldPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -154,7 +154,7 @@ pub(crate) async fn get_field_type_option_data_handler(
|
||||
}
|
||||
|
||||
/// Create FieldMeta and save it. Return the FieldTypeOptionData.
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn create_field_type_option_data_handler(
|
||||
data: Data<EditFieldPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -171,7 +171,7 @@ pub(crate) async fn create_field_type_option_data_handler(
|
||||
})
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn move_item_handler(
|
||||
data: Data<MoveItemPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -252,7 +252,7 @@ pub(crate) async fn get_cell_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn update_cell_handler(
|
||||
data: Data<CellChangeset>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -263,7 +263,7 @@ pub(crate) async fn update_cell_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn get_date_cell_data_handler(
|
||||
data: Data<CellIdentifierPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -284,7 +284,7 @@ pub(crate) async fn get_date_cell_data_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn new_select_option_handler(
|
||||
data: Data<CreateSelectOptionPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -301,7 +301,7 @@ pub(crate) async fn new_select_option_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn update_select_option_handler(
|
||||
data: Data<SelectOptionChangesetPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -341,7 +341,7 @@ pub(crate) async fn update_select_option_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager), err)]
|
||||
#[tracing::instrument(level = "trace", skip(data, manager), err)]
|
||||
pub(crate) async fn get_select_option_handler(
|
||||
data: Data<CellIdentifierPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -362,7 +362,7 @@ pub(crate) async fn get_select_option_handler(
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn update_select_option_cell_handler(
|
||||
data: Data<SelectOptionCellChangesetPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
@ -373,7 +373,7 @@ pub(crate) async fn update_select_option_cell_handler(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub(crate) async fn update_date_cell_handler(
|
||||
data: Data<DateChangesetPayload>,
|
||||
manager: AppData<Arc<GridManager>>,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::services::grid_editor::ClientGridEditor;
|
||||
use crate::services::persistence::block_index::BlockIndexPersistence;
|
||||
use crate::services::grid_editor::GridMetaEditor;
|
||||
use crate::services::persistence::block_index::BlockIndexCache;
|
||||
use crate::services::persistence::kv::GridKVPersistence;
|
||||
use crate::services::persistence::GridDatabase;
|
||||
use bytes::Bytes;
|
||||
@ -20,9 +20,9 @@ pub trait GridUser: Send + Sync {
|
||||
}
|
||||
|
||||
pub struct GridManager {
|
||||
editor_map: Arc<GridEditorMap>,
|
||||
editor_map: Arc<DashMap<String, Arc<GridMetaEditor>>>,
|
||||
grid_user: Arc<dyn GridUser>,
|
||||
block_index_persistence: Arc<BlockIndexPersistence>,
|
||||
block_index_cache: Arc<BlockIndexCache>,
|
||||
#[allow(dead_code)]
|
||||
kv_persistence: Arc<GridKVPersistence>,
|
||||
}
|
||||
@ -33,14 +33,14 @@ impl GridManager {
|
||||
_rev_web_socket: Arc<dyn RevisionWebSocket>,
|
||||
database: Arc<dyn GridDatabase>,
|
||||
) -> Self {
|
||||
let grid_editors = Arc::new(GridEditorMap::new());
|
||||
let grid_editors = Arc::new(DashMap::new());
|
||||
let kv_persistence = Arc::new(GridKVPersistence::new(database.clone()));
|
||||
let block_index_persistence = Arc::new(BlockIndexPersistence::new(database));
|
||||
let block_index_persistence = Arc::new(BlockIndexCache::new(database));
|
||||
Self {
|
||||
editor_map: grid_editors,
|
||||
grid_user,
|
||||
kv_persistence,
|
||||
block_index_persistence,
|
||||
block_index_cache: block_index_persistence,
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ impl GridManager {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, fields(grid_id), err)]
|
||||
pub async fn open_grid<T: AsRef<str>>(&self, grid_id: T) -> FlowyResult<Arc<ClientGridEditor>> {
|
||||
pub async fn open_grid<T: AsRef<str>>(&self, grid_id: T) -> FlowyResult<Arc<GridMetaEditor>> {
|
||||
let grid_id = grid_id.as_ref();
|
||||
tracing::Span::current().record("grid_id", &grid_id);
|
||||
self.get_or_create_grid_editor(grid_id).await
|
||||
@ -90,23 +90,27 @@ impl GridManager {
|
||||
}
|
||||
|
||||
// #[tracing::instrument(level = "debug", skip(self), err)]
|
||||
pub fn get_grid_editor(&self, grid_id: &str) -> FlowyResult<Arc<ClientGridEditor>> {
|
||||
pub fn get_grid_editor(&self, grid_id: &str) -> FlowyResult<Arc<GridMetaEditor>> {
|
||||
match self.editor_map.get(grid_id) {
|
||||
None => Err(FlowyError::internal().context("Should call open_grid function first")),
|
||||
Some(editor) => Ok(editor),
|
||||
Some(editor) => Ok(editor.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_or_create_grid_editor(&self, grid_id: &str) -> FlowyResult<Arc<ClientGridEditor>> {
|
||||
async fn get_or_create_grid_editor(&self, grid_id: &str) -> FlowyResult<Arc<GridMetaEditor>> {
|
||||
match self.editor_map.get(grid_id) {
|
||||
None => {
|
||||
tracing::trace!("Create grid editor with id: {}", grid_id);
|
||||
let db_pool = self.grid_user.db_pool()?;
|
||||
let editor = self.make_grid_editor(grid_id, db_pool).await?;
|
||||
self.editor_map.insert(grid_id, &editor);
|
||||
|
||||
if self.editor_map.contains_key(grid_id) {
|
||||
tracing::warn!("Grid:{} already exists in cache", grid_id);
|
||||
}
|
||||
self.editor_map.insert(grid_id.to_string(), editor.clone());
|
||||
Ok(editor)
|
||||
}
|
||||
Some(editor) => Ok(editor),
|
||||
Some(editor) => Ok(editor.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,11 +119,10 @@ impl GridManager {
|
||||
&self,
|
||||
grid_id: &str,
|
||||
pool: Arc<ConnectionPool>,
|
||||
) -> Result<Arc<ClientGridEditor>, FlowyError> {
|
||||
) -> Result<Arc<GridMetaEditor>, FlowyError> {
|
||||
let user = self.grid_user.clone();
|
||||
let rev_manager = self.make_grid_rev_manager(grid_id, pool.clone())?;
|
||||
let grid_editor =
|
||||
ClientGridEditor::new(grid_id, user, rev_manager, self.block_index_persistence.clone()).await?;
|
||||
let grid_editor = GridMetaEditor::new(grid_id, user, rev_manager, self.block_index_cache.clone()).await?;
|
||||
Ok(grid_editor)
|
||||
}
|
||||
|
||||
@ -145,31 +148,6 @@ impl GridManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GridEditorMap {
|
||||
inner: DashMap<String, Arc<ClientGridEditor>>,
|
||||
}
|
||||
|
||||
impl GridEditorMap {
|
||||
fn new() -> Self {
|
||||
Self { inner: DashMap::new() }
|
||||
}
|
||||
|
||||
pub(crate) fn insert(&self, grid_id: &str, grid_editor: &Arc<ClientGridEditor>) {
|
||||
if self.inner.contains_key(grid_id) {
|
||||
tracing::warn!("Grid:{} already exists in cache", grid_id);
|
||||
}
|
||||
self.inner.insert(grid_id.to_string(), grid_editor.clone());
|
||||
}
|
||||
|
||||
pub(crate) fn get(&self, grid_id: &str) -> Option<Arc<ClientGridEditor>> {
|
||||
Some(self.inner.get(grid_id)?.clone())
|
||||
}
|
||||
|
||||
pub(crate) fn remove(&self, grid_id: &str) {
|
||||
self.inner.remove(grid_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn make_grid_view_data(
|
||||
user_id: &str,
|
||||
view_id: &str,
|
||||
@ -192,9 +170,7 @@ pub async fn make_grid_view_data(
|
||||
|
||||
// Indexing the block's rows
|
||||
build_context.block_meta_data.rows.iter().for_each(|row| {
|
||||
let _ = grid_manager
|
||||
.block_index_persistence
|
||||
.insert_or_update(&row.block_id, &row.id);
|
||||
let _ = grid_manager.block_index_cache.insert(&row.block_id, &row.id);
|
||||
});
|
||||
|
||||
// Create grid's block
|
||||
|
@ -8,18 +8,17 @@ use flowy_sync::util::make_delta_from_revisions;
|
||||
use lib_infra::future::FutureResult;
|
||||
use lib_ot::core::PlainTextAttributes;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub struct ClientGridBlockMetaEditor {
|
||||
pub struct GridBlockMetaEditor {
|
||||
user_id: String,
|
||||
pub block_id: String,
|
||||
pad: Arc<RwLock<GridBlockMetaPad>>,
|
||||
rev_manager: Arc<RevisionManager>,
|
||||
}
|
||||
|
||||
impl ClientGridBlockMetaEditor {
|
||||
impl GridBlockMetaEditor {
|
||||
pub async fn new(
|
||||
user_id: &str,
|
||||
token: &str,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::block_meta_editor::ClientGridBlockMetaEditor;
|
||||
use crate::services::persistence::block_index::BlockIndexPersistence;
|
||||
use crate::services::block_meta_editor::GridBlockMetaEditor;
|
||||
use crate::services::persistence::block_index::BlockIndexCache;
|
||||
use crate::services::row::{group_row_orders, GridBlockSnapshot};
|
||||
use dashmap::DashMap;
|
||||
use flowy_error::FlowyResult;
|
||||
@ -15,20 +15,20 @@ use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) struct GridBlockMetaEditorManager {
|
||||
type BlockId = String;
|
||||
pub(crate) struct GridBlockManager {
|
||||
grid_id: String,
|
||||
user: Arc<dyn GridUser>,
|
||||
// Key: block_id
|
||||
editor_map: DashMap<String, Arc<ClientGridBlockMetaEditor>>,
|
||||
persistence: Arc<BlockIndexPersistence>,
|
||||
persistence: Arc<BlockIndexCache>,
|
||||
block_editor_map: DashMap<BlockId, Arc<GridBlockMetaEditor>>,
|
||||
}
|
||||
|
||||
impl GridBlockMetaEditorManager {
|
||||
impl GridBlockManager {
|
||||
pub(crate) async fn new(
|
||||
grid_id: &str,
|
||||
user: &Arc<dyn GridUser>,
|
||||
blocks: Vec<GridBlockMeta>,
|
||||
persistence: Arc<BlockIndexPersistence>,
|
||||
persistence: Arc<BlockIndexCache>,
|
||||
) -> FlowyResult<Self> {
|
||||
let editor_map = make_block_meta_editor_map(user, blocks).await?;
|
||||
let user = user.clone();
|
||||
@ -36,27 +36,27 @@ impl GridBlockMetaEditorManager {
|
||||
let manager = Self {
|
||||
grid_id,
|
||||
user,
|
||||
editor_map,
|
||||
block_editor_map: editor_map,
|
||||
persistence,
|
||||
};
|
||||
Ok(manager)
|
||||
}
|
||||
|
||||
// #[tracing::instrument(level = "trace", skip(self))]
|
||||
pub(crate) async fn get_editor(&self, block_id: &str) -> FlowyResult<Arc<ClientGridBlockMetaEditor>> {
|
||||
pub(crate) async fn get_editor(&self, block_id: &str) -> FlowyResult<Arc<GridBlockMetaEditor>> {
|
||||
debug_assert!(!block_id.is_empty());
|
||||
match self.editor_map.get(block_id) {
|
||||
match self.block_editor_map.get(block_id) {
|
||||
None => {
|
||||
tracing::error!("The is a fatal error, block is not exist");
|
||||
let editor = Arc::new(make_block_meta_editor(&self.user, block_id).await?);
|
||||
self.editor_map.insert(block_id.to_owned(), editor.clone());
|
||||
self.block_editor_map.insert(block_id.to_owned(), editor.clone());
|
||||
Ok(editor)
|
||||
}
|
||||
Some(editor) => Ok(editor.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_editor_from_row_id(&self, row_id: &str) -> FlowyResult<Arc<ClientGridBlockMetaEditor>> {
|
||||
async fn get_editor_from_row_id(&self, row_id: &str) -> FlowyResult<Arc<GridBlockMetaEditor>> {
|
||||
let block_id = self.persistence.get_block_id(row_id)?;
|
||||
Ok(self.get_editor(&block_id).await?)
|
||||
}
|
||||
@ -67,7 +67,7 @@ impl GridBlockMetaEditorManager {
|
||||
row_meta: RowMeta,
|
||||
start_row_id: Option<String>,
|
||||
) -> FlowyResult<i32> {
|
||||
let _ = self.persistence.insert_or_update(&row_meta.block_id, &row_meta.id)?;
|
||||
let _ = self.persistence.insert(&row_meta.block_id, &row_meta.id)?;
|
||||
let editor = self.get_editor(&row_meta.block_id).await?;
|
||||
|
||||
let mut index_row_order = IndexRowOrder::from(&row_meta);
|
||||
@ -90,7 +90,7 @@ impl GridBlockMetaEditorManager {
|
||||
let editor = self.get_editor(&block_id).await?;
|
||||
let mut row_count = 0;
|
||||
for row in row_metas {
|
||||
let _ = self.persistence.insert_or_update(&row.block_id, &row.id)?;
|
||||
let _ = self.persistence.insert(&row.block_id, &row.id)?;
|
||||
let mut row_order = IndexRowOrder::from(&row);
|
||||
let (count, index) = editor.create_row(row, None).await?;
|
||||
row_count = count;
|
||||
@ -256,7 +256,7 @@ impl GridBlockMetaEditorManager {
|
||||
async fn make_block_meta_editor_map(
|
||||
user: &Arc<dyn GridUser>,
|
||||
blocks: Vec<GridBlockMeta>,
|
||||
) -> FlowyResult<DashMap<String, Arc<ClientGridBlockMetaEditor>>> {
|
||||
) -> FlowyResult<DashMap<String, Arc<GridBlockMetaEditor>>> {
|
||||
let editor_map = DashMap::new();
|
||||
for block in blocks {
|
||||
let editor = make_block_meta_editor(user, &block.block_id).await?;
|
||||
@ -266,7 +266,7 @@ async fn make_block_meta_editor_map(
|
||||
Ok(editor_map)
|
||||
}
|
||||
|
||||
async fn make_block_meta_editor(user: &Arc<dyn GridUser>, block_id: &str) -> FlowyResult<ClientGridBlockMetaEditor> {
|
||||
async fn make_block_meta_editor(user: &Arc<dyn GridUser>, block_id: &str) -> FlowyResult<GridBlockMetaEditor> {
|
||||
let token = user.token()?;
|
||||
let user_id = user.user_id()?;
|
||||
let pool = user.db_pool()?;
|
||||
@ -274,5 +274,5 @@ async fn make_block_meta_editor(user: &Arc<dyn GridUser>, block_id: &str) -> Flo
|
||||
let disk_cache = Arc::new(SQLiteGridBlockMetaRevisionPersistence::new(&user_id, pool));
|
||||
let rev_persistence = Arc::new(RevisionPersistence::new(&user_id, block_id, disk_cache));
|
||||
let rev_manager = RevisionManager::new(&user_id, block_id, rev_persistence);
|
||||
ClientGridBlockMetaEditor::new(&user_id, &token, block_id, rev_manager).await
|
||||
GridBlockMetaEditor::new(&user_id, &token, block_id, rev_manager).await
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridNotification};
|
||||
use crate::entities::CellIdentifier;
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::block_meta_manager::GridBlockMetaEditorManager;
|
||||
use crate::services::block_meta_manager::GridBlockManager;
|
||||
use crate::services::field::{default_type_option_builder_from_type, type_option_builder_from_bytes, FieldBuilder};
|
||||
use crate::services::persistence::block_index::BlockIndexPersistence;
|
||||
use crate::services::persistence::block_index::BlockIndexCache;
|
||||
use crate::services::row::*;
|
||||
use bytes::Bytes;
|
||||
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
||||
@ -19,20 +19,26 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub struct ClientGridEditor {
|
||||
pub struct GridMetaEditor {
|
||||
grid_id: String,
|
||||
user: Arc<dyn GridUser>,
|
||||
grid_pad: Arc<RwLock<GridMetaPad>>,
|
||||
rev_manager: Arc<RevisionManager>,
|
||||
block_meta_manager: Arc<GridBlockMetaEditorManager>,
|
||||
block_manager: Arc<GridBlockManager>,
|
||||
}
|
||||
|
||||
impl ClientGridEditor {
|
||||
impl Drop for GridMetaEditor {
|
||||
fn drop(&mut self) {
|
||||
tracing::trace!("Drop GridMetaEditor");
|
||||
}
|
||||
}
|
||||
|
||||
impl GridMetaEditor {
|
||||
pub async fn new(
|
||||
grid_id: &str,
|
||||
user: Arc<dyn GridUser>,
|
||||
mut rev_manager: RevisionManager,
|
||||
persistence: Arc<BlockIndexPersistence>,
|
||||
persistence: Arc<BlockIndexCache>,
|
||||
) -> FlowyResult<Arc<Self>> {
|
||||
let token = user.token()?;
|
||||
let cloud = Arc::new(GridRevisionCloudService { token });
|
||||
@ -41,13 +47,13 @@ impl ClientGridEditor {
|
||||
let grid_pad = Arc::new(RwLock::new(grid_pad));
|
||||
let blocks = grid_pad.read().await.get_block_metas();
|
||||
|
||||
let block_meta_manager = Arc::new(GridBlockMetaEditorManager::new(grid_id, &user, blocks, persistence).await?);
|
||||
let block_meta_manager = Arc::new(GridBlockManager::new(grid_id, &user, blocks, persistence).await?);
|
||||
Ok(Arc::new(Self {
|
||||
grid_id: grid_id.to_owned(),
|
||||
user,
|
||||
grid_pad,
|
||||
rev_manager,
|
||||
block_meta_manager,
|
||||
block_manager: block_meta_manager,
|
||||
}))
|
||||
}
|
||||
|
||||
@ -254,10 +260,7 @@ impl ClientGridEditor {
|
||||
let row_order = RowOrder::from(&row_meta);
|
||||
|
||||
// insert the row
|
||||
let row_count = self
|
||||
.block_meta_manager
|
||||
.create_row(&block_id, row_meta, start_row_id)
|
||||
.await?;
|
||||
let row_count = self.block_manager.create_row(&block_id, row_meta, start_row_id).await?;
|
||||
|
||||
// update block row count
|
||||
let changeset = GridBlockMetaChangeset::from_row_count(&block_id, row_count);
|
||||
@ -277,7 +280,7 @@ impl ClientGridEditor {
|
||||
.or_insert_with(Vec::new)
|
||||
.push(row_meta);
|
||||
}
|
||||
let changesets = self.block_meta_manager.insert_row(rows_by_block_id).await?;
|
||||
let changesets = self.block_manager.insert_row(rows_by_block_id).await?;
|
||||
for changeset in changesets {
|
||||
let _ = self.update_block(changeset).await?;
|
||||
}
|
||||
@ -286,7 +289,7 @@ impl ClientGridEditor {
|
||||
|
||||
pub async fn update_row(&self, changeset: RowMetaChangeset) -> FlowyResult<()> {
|
||||
let field_metas = self.get_field_metas::<FieldOrder>(None).await?;
|
||||
self.block_meta_manager
|
||||
self.block_manager
|
||||
.update_row(changeset, |row_meta| make_row_from_row_meta(&field_metas, row_meta))
|
||||
.await
|
||||
}
|
||||
@ -309,7 +312,7 @@ impl ClientGridEditor {
|
||||
}
|
||||
|
||||
pub async fn get_row(&self, row_id: &str) -> FlowyResult<Option<Row>> {
|
||||
match self.block_meta_manager.get_row_meta(row_id).await? {
|
||||
match self.block_manager.get_row_meta(row_id).await? {
|
||||
None => Ok(None),
|
||||
Some(row_meta) => {
|
||||
let field_metas = self.get_field_metas::<FieldOrder>(None).await?;
|
||||
@ -321,7 +324,7 @@ impl ClientGridEditor {
|
||||
}
|
||||
}
|
||||
pub async fn delete_row(&self, row_id: &str) -> FlowyResult<()> {
|
||||
let _ = self.block_meta_manager.delete_row(row_id).await?;
|
||||
let _ = self.block_manager.delete_row(row_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -331,12 +334,12 @@ impl ClientGridEditor {
|
||||
|
||||
pub async fn get_cell(&self, params: &CellIdentifier) -> Option<Cell> {
|
||||
let field_meta = self.get_field_meta(¶ms.field_id).await?;
|
||||
let row_meta = self.block_meta_manager.get_row_meta(¶ms.row_id).await.ok()??;
|
||||
let row_meta = self.block_manager.get_row_meta(¶ms.row_id).await.ok()??;
|
||||
make_cell(¶ms.field_id, &field_meta, &row_meta)
|
||||
}
|
||||
|
||||
pub async fn get_cell_meta(&self, row_id: &str, field_id: &str) -> FlowyResult<Option<CellMeta>> {
|
||||
let row_meta = self.block_meta_manager.get_row_meta(row_id).await?;
|
||||
let row_meta = self.block_manager.get_row_meta(row_id).await?;
|
||||
match row_meta {
|
||||
None => Ok(None),
|
||||
Some(row_meta) => {
|
||||
@ -382,7 +385,7 @@ impl ClientGridEditor {
|
||||
cell_content_changeset,
|
||||
};
|
||||
let _ = self
|
||||
.block_meta_manager
|
||||
.block_manager
|
||||
.update_cell(cell_changeset, |row_meta| {
|
||||
make_row_from_row_meta(&field_metas, row_meta)
|
||||
})
|
||||
@ -403,7 +406,7 @@ impl ClientGridEditor {
|
||||
}
|
||||
|
||||
pub async fn delete_rows(&self, row_orders: Vec<RowOrder>) -> FlowyResult<()> {
|
||||
let changesets = self.block_meta_manager.delete_rows(row_orders).await?;
|
||||
let changesets = self.block_manager.delete_rows(row_orders).await?;
|
||||
for changeset in changesets {
|
||||
let _ = self.update_block(changeset).await?;
|
||||
}
|
||||
@ -415,7 +418,7 @@ impl ClientGridEditor {
|
||||
let field_orders = pad_read_guard.get_field_orders();
|
||||
let mut block_orders = vec![];
|
||||
for block_order in pad_read_guard.get_block_metas() {
|
||||
let row_orders = self.block_meta_manager.get_row_orders(&block_order.block_id).await?;
|
||||
let row_orders = self.block_manager.get_row_orders(&block_order.block_id).await?;
|
||||
let block_order = GridBlockOrder {
|
||||
block_id: block_order.block_id,
|
||||
row_orders,
|
||||
@ -442,7 +445,7 @@ impl ClientGridEditor {
|
||||
.collect::<Vec<String>>(),
|
||||
Some(block_ids) => block_ids,
|
||||
};
|
||||
let snapshots = self.block_meta_manager.make_block_snapshots(block_ids).await?;
|
||||
let snapshots = self.block_manager.make_block_snapshots(block_ids).await?;
|
||||
Ok(snapshots)
|
||||
}
|
||||
|
||||
@ -476,10 +479,7 @@ impl ClientGridEditor {
|
||||
}
|
||||
|
||||
pub async fn move_row(&self, row_id: &str, from: i32, to: i32) -> FlowyResult<()> {
|
||||
let _ = self
|
||||
.block_meta_manager
|
||||
.move_row(row_id, from as usize, to as usize)
|
||||
.await?;
|
||||
let _ = self.block_manager.move_row(row_id, from as usize, to as usize).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ impl ClientGridEditor {
|
||||
}
|
||||
|
||||
#[cfg(feature = "flowy_unit_test")]
|
||||
impl ClientGridEditor {
|
||||
impl GridMetaEditor {
|
||||
pub fn rev_manager(&self) -> Arc<RevisionManager> {
|
||||
self.rev_manager.clone()
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ use flowy_database::{
|
||||
use flowy_error::FlowyResult;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct BlockIndexPersistence {
|
||||
pub struct BlockIndexCache {
|
||||
database: Arc<dyn GridDatabase>,
|
||||
}
|
||||
|
||||
impl BlockIndexPersistence {
|
||||
impl BlockIndexCache {
|
||||
pub fn new(database: Arc<dyn GridDatabase>) -> Self {
|
||||
Self { database }
|
||||
}
|
||||
@ -26,7 +26,7 @@ impl BlockIndexPersistence {
|
||||
Ok(block_id)
|
||||
}
|
||||
|
||||
pub fn insert_or_update(&self, block_id: &str, row_id: &str) -> FlowyResult<()> {
|
||||
pub fn insert(&self, block_id: &str, row_id: &str) -> FlowyResult<()> {
|
||||
let conn = self.database.db_connection()?;
|
||||
let item = IndexItem {
|
||||
row_id: row_id.to_string(),
|
||||
|
@ -1,6 +1,6 @@
|
||||
use bytes::Bytes;
|
||||
use flowy_grid::services::field::*;
|
||||
use flowy_grid::services::grid_editor::{ClientGridEditor, GridPadBuilder};
|
||||
use flowy_grid::services::grid_editor::{GridMetaEditor, GridPadBuilder};
|
||||
use flowy_grid::services::row::CreateRowMetaPayload;
|
||||
use flowy_grid_data_model::entities::{
|
||||
BuildGridContext, CellChangeset, Field, FieldChangesetParams, FieldMeta, FieldOrder, FieldType, GridBlockMeta,
|
||||
@ -72,7 +72,7 @@ pub enum EditorScript {
|
||||
pub struct GridEditorTest {
|
||||
pub sdk: FlowySDKTest,
|
||||
pub grid_id: String,
|
||||
pub editor: Arc<ClientGridEditor>,
|
||||
pub editor: Arc<GridMetaEditor>,
|
||||
pub field_metas: Vec<FieldMeta>,
|
||||
pub grid_blocks: Vec<GridBlockMeta>,
|
||||
pub row_metas: Vec<Arc<RowMeta>>,
|
||||
@ -239,7 +239,7 @@ impl GridEditorTest {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_row_metas(editor: &Arc<ClientGridEditor>) -> Vec<Arc<RowMeta>> {
|
||||
async fn get_row_metas(editor: &Arc<GridMetaEditor>) -> Vec<Arc<RowMeta>> {
|
||||
editor
|
||||
.grid_block_snapshots(None)
|
||||
.await
|
||||
|
@ -21,7 +21,7 @@ use lib_ws::WSConnectState;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
pub struct ClientTextBlockEditor {
|
||||
pub struct TextBlockEditor {
|
||||
pub doc_id: String,
|
||||
#[allow(dead_code)]
|
||||
rev_manager: Arc<RevisionManager>,
|
||||
@ -30,7 +30,7 @@ pub struct ClientTextBlockEditor {
|
||||
edit_cmd_tx: EditorCommandSender,
|
||||
}
|
||||
|
||||
impl ClientTextBlockEditor {
|
||||
impl TextBlockEditor {
|
||||
#[allow(unused_variables)]
|
||||
pub(crate) async fn new(
|
||||
doc_id: &str,
|
||||
@ -185,7 +185,7 @@ impl ClientTextBlockEditor {
|
||||
pub(crate) fn receive_ws_state(&self, _state: &WSConnectState) {}
|
||||
}
|
||||
|
||||
impl std::ops::Drop for ClientTextBlockEditor {
|
||||
impl std::ops::Drop for TextBlockEditor {
|
||||
fn drop(&mut self) {
|
||||
tracing::trace!("{} ClientBlockEditor was dropped", self.doc_id)
|
||||
}
|
||||
@ -204,7 +204,7 @@ fn spawn_edit_queue(
|
||||
}
|
||||
|
||||
#[cfg(feature = "flowy_unit_test")]
|
||||
impl ClientTextBlockEditor {
|
||||
impl TextBlockEditor {
|
||||
pub async fn text_block_delta(&self) -> FlowyResult<RichTextDelta> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<RichTextDelta>>();
|
||||
let msg = EditorCommand::ReadDelta { ret };
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{editor::ClientTextBlockEditor, errors::FlowyError, BlockCloudService};
|
||||
use crate::{editor::TextBlockEditor, errors::FlowyError, BlockCloudService};
|
||||
use bytes::Bytes;
|
||||
use dashmap::DashMap;
|
||||
use flowy_database::ConnectionPool;
|
||||
@ -47,8 +47,8 @@ impl TextBlockManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, block_id), fields(block_id), err)]
|
||||
pub async fn open_block<T: AsRef<str>>(&self, block_id: T) -> Result<Arc<ClientTextBlockEditor>, FlowyError> {
|
||||
#[tracing::instrument(level = "trace", skip(self, block_id), fields(block_id), err)]
|
||||
pub async fn open_block<T: AsRef<str>>(&self, block_id: T) -> Result<Arc<TextBlockEditor>, FlowyError> {
|
||||
let block_id = block_id.as_ref();
|
||||
tracing::Span::current().record("block_id", &block_id);
|
||||
self.get_block_editor(block_id).await
|
||||
@ -108,7 +108,7 @@ impl TextBlockManager {
|
||||
}
|
||||
|
||||
impl TextBlockManager {
|
||||
async fn get_block_editor(&self, block_id: &str) -> FlowyResult<Arc<ClientTextBlockEditor>> {
|
||||
async fn get_block_editor(&self, block_id: &str) -> FlowyResult<Arc<TextBlockEditor>> {
|
||||
match self.editor_map.get(block_id) {
|
||||
None => {
|
||||
let db_pool = self.user.db_pool()?;
|
||||
@ -123,7 +123,7 @@ impl TextBlockManager {
|
||||
&self,
|
||||
block_id: &str,
|
||||
pool: Arc<ConnectionPool>,
|
||||
) -> Result<Arc<ClientTextBlockEditor>, FlowyError> {
|
||||
) -> Result<Arc<TextBlockEditor>, FlowyError> {
|
||||
let user = self.user.clone();
|
||||
let token = self.user.token()?;
|
||||
let rev_manager = self.make_rev_manager(block_id, pool.clone())?;
|
||||
@ -132,7 +132,7 @@ impl TextBlockManager {
|
||||
server: self.cloud_service.clone(),
|
||||
});
|
||||
let doc_editor =
|
||||
ClientTextBlockEditor::new(block_id, user, rev_manager, self.rev_web_socket.clone(), cloud_service).await?;
|
||||
TextBlockEditor::new(block_id, user, rev_manager, self.rev_web_socket.clone(), cloud_service).await?;
|
||||
self.editor_map.insert(block_id, &doc_editor);
|
||||
Ok(doc_editor)
|
||||
}
|
||||
@ -180,7 +180,7 @@ impl RevisionCloudService for TextBlockRevisionCloudService {
|
||||
}
|
||||
|
||||
pub struct TextBlockEditorMap {
|
||||
inner: DashMap<String, Arc<ClientTextBlockEditor>>,
|
||||
inner: DashMap<String, Arc<TextBlockEditor>>,
|
||||
}
|
||||
|
||||
impl TextBlockEditorMap {
|
||||
@ -188,14 +188,14 @@ impl TextBlockEditorMap {
|
||||
Self { inner: DashMap::new() }
|
||||
}
|
||||
|
||||
pub(crate) fn insert(&self, block_id: &str, doc: &Arc<ClientTextBlockEditor>) {
|
||||
pub(crate) fn insert(&self, block_id: &str, doc: &Arc<TextBlockEditor>) {
|
||||
if self.inner.contains_key(block_id) {
|
||||
log::warn!("Doc:{} already exists in cache", block_id);
|
||||
}
|
||||
self.inner.insert(block_id.to_string(), doc.clone());
|
||||
}
|
||||
|
||||
pub(crate) fn get(&self, block_id: &str) -> Option<Arc<ClientTextBlockEditor>> {
|
||||
pub(crate) fn get(&self, block_id: &str) -> Option<Arc<TextBlockEditor>> {
|
||||
Some(self.inner.get(block_id)?.clone())
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use flowy_revision::disk::RevisionState;
|
||||
use flowy_test::{helper::ViewTest, FlowySDKTest};
|
||||
use flowy_text_block::editor::ClientTextBlockEditor;
|
||||
use flowy_text_block::editor::TextBlockEditor;
|
||||
use flowy_text_block::TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS;
|
||||
use lib_ot::{core::Interval, rich_text::RichTextDelta};
|
||||
use std::sync::Arc;
|
||||
@ -19,7 +19,7 @@ pub enum EditorScript {
|
||||
|
||||
pub struct TextBlockEditorTest {
|
||||
pub sdk: FlowySDKTest,
|
||||
pub editor: Arc<ClientTextBlockEditor>,
|
||||
pub editor: Arc<TextBlockEditor>,
|
||||
}
|
||||
|
||||
impl TextBlockEditorTest {
|
||||
|
@ -175,7 +175,7 @@ impl GridBlockMetaPad {
|
||||
match cal_diff::<PlainTextAttributes>(old, new) {
|
||||
None => Ok(None),
|
||||
Some(delta) => {
|
||||
tracing::debug!("[GridBlockMeta] Composing delta {}", delta.to_delta_str());
|
||||
tracing::trace!("[GridBlockMeta] Composing delta {}", delta.to_delta_str());
|
||||
// tracing::debug!(
|
||||
// "[GridBlockMeta] current delta: {}",
|
||||
// self.delta.to_str().unwrap_or_else(|_| "".to_string())
|
||||
|
Loading…
Reference in New Issue
Block a user