mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: rename structs
This commit is contained in:
parent
b93feb49c3
commit
d08f298fb6
@ -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)]
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user