Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: rename structs
appflowyd08f298fb6a2
diff --git a/frontend/rust-lib/flowy-grid/src/event_handler.rs b/frontend/rust-lib/flowy-grid/src/event_handler.rsindex d94753c4b0..1ac3796059 100644--- a/frontend/rust-lib/flowy-grid/src/event_handler.rs+++ b/frontend/rust-lib/flowy-grid/src/event_handler.rs@@ -183,16 +183,22 @@ pub(crate) async fn get_row_handler(pub(crate) async fn delete_row_handler(data: Data<RowIdentifierPayload>,manager: AppData<Arc<GridManager>>,-) -> DataResult<Row, FlowyError> {- todo!()+) -> Result<(), FlowyError> {+ let params: RowIdentifier = data.into_inner().try_into()?;+ let editor = manager.get_grid_editor(¶ms.grid_id)?;+ let _ = editor.delete_row(¶ms.row_id)?;+ Ok(())}#[tracing::instrument(level = "debug", skip(data, manager), err)]pub(crate) async fn duplicate_row_handler(data: Data<RowIdentifierPayload>,manager: AppData<Arc<GridManager>>,-) -> DataResult<Row, FlowyError> {- todo!()+) -> Result<(), FlowyError> {+ let params: RowIdentifier = data.into_inner().try_into()?;+ let editor = manager.get_grid_editor(¶ms.grid_id)?;+ let _ = editor.duplicate_row(¶ms.row_id)?;+ Ok(())}#[tracing::instrument(level = "debug", skip(data, manager), err)]diff --git a/frontend/rust-lib/flowy-grid/src/services/block_meta_manager.rs b/frontend/rust-lib/flowy-grid/src/services/block_meta_manager.rsindex 104b6fbbdb..54e223c242 100644--- a/frontend/rust-lib/flowy-grid/src/services/block_meta_manager.rs+++ b/frontend/rust-lib/flowy-grid/src/services/block_meta_manager.rs@@ -2,7 +2,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::row::{make_block_row_ids, make_rows_from_row_metas, GridBlockSnapshot};+use crate::services::row::{make_block_rows, make_rows_from_row_metas, GridBlockSnapshot};use dashmap::DashMap;use flowy_error::FlowyResult;@@ -94,11 +94,11 @@ impl GridBlockMetaEditorManager {pub(crate) async fn delete_rows(&self, row_orders: Vec<RowOrder>) -> FlowyResult<Vec<GridBlockMetaChangeset>> {let mut changesets = vec![];- for block_row_ids in make_block_row_ids(&row_orders) {- let editor = self.get_editor(&block_row_ids.block_id).await?;- let row_count = editor.delete_rows(block_row_ids.row_ids).await?;+ for block_row in make_block_rows(&row_orders) {+ let editor = self.get_editor(&block_row.block_id).await?;+ let row_count = editor.delete_rows(block_row.row_ids).await?;- let changeset = GridBlockMetaChangeset::from_row_count(&block_row_ids.block_id, row_count);+ let changeset = GridBlockMetaChangeset::from_row_count(&block_row.block_id, row_count);changesets.push(changeset);}diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rsindex b934d4bc35..1753013760 100644--- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs+++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs@@ -267,6 +267,13 @@ impl ClientGridEditor {}}}+ pub async fn delete_row(&self, row_id: &str) -> FlowyResult<()> {+ todo!()+ }++ pub async fn duplicate_row(&self, row_id: &str) -> FlowyResult<()> {+ todo!()+ }pub async fn get_cell(&self, params: &CellIdentifier) -> Option<Cell> {let field_meta = self.get_field_meta(¶ms.field_id).await?;@@ -316,6 +323,11 @@ impl ClientGridEditor {Ok(grid_blocks)}+ // pub async fn get_field_metas<T>(&self, field_ids: Option<Vec<T>>) -> FlowyResult<Vec<FieldMeta>>+ // where+ // T: Into<FieldOrder>,+ // {+pub async fn delete_rows(&self, row_orders: Vec<RowOrder>) -> FlowyResult<()> {let changesets = self.block_meta_manager.delete_rows(row_orders).await?;for changeset in changesets {diff --git a/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs b/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rsindex 89f7db216c..ac26f1d32c 100644--- a/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs+++ b/frontend/rust-lib/flowy-grid/src/services/row/row_loader.rs@@ -8,14 +8,14 @@ use std::collections::HashMap;use std::sync::Arc;-pub(crate) struct BlockRowIds {+pub(crate) struct BlockRows {pub(crate) block_id: String,pub(crate) row_ids: Vec<String>,}-impl BlockRowIds {+impl BlockRows {pub fn new(block_id: &str) -> Self {- BlockRowIds {+ BlockRows {block_id: block_id.to_owned(),row_ids: vec![],}@@ -27,13 +27,13 @@ pub struct GridBlockSnapshot {pub row_metas: Vec<Arc<RowMeta>>,}-pub(crate) fn make_block_row_ids(row_orders: &[RowOrder]) -> Vec<BlockRowIds> {- let mut map: HashMap<&String, BlockRowIds> = HashMap::new();+pub(crate) fn make_block_rows(row_orders: &[RowOrder]) -> Vec<BlockRows> {+ let mut map: HashMap<&String, BlockRows> = HashMap::new();row_orders.iter().for_each(|row_order| {let block_id = &row_order.block_id;let row_id = row_order.row_id.clone();map.entry(block_id)- .or_insert_with(|| BlockRowIds::new(block_id))+ .or_insert_with(|| BlockRows::new(block_id)).row_ids.push(row_id);});