mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: options don't refresh after moving the card (#1536)
Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
parent
72dc0b8f67
commit
a2f9ca2f28
@ -97,11 +97,22 @@ class GridRowCache {
|
||||
}
|
||||
}
|
||||
|
||||
void _updateRows(List<RowPB> updatedRows) {
|
||||
void _updateRows(List<UpdatedRowPB> updatedRows) {
|
||||
if (updatedRows.isEmpty) return;
|
||||
List<RowPB> rowPBs = [];
|
||||
for (final updatedRow in updatedRows) {
|
||||
for (final fieldId in updatedRow.fieldIds) {
|
||||
final key = GridCellCacheKey(
|
||||
fieldId: fieldId,
|
||||
rowId: updatedRow.row.id,
|
||||
);
|
||||
_cellCache.remove(key);
|
||||
}
|
||||
rowPBs.add(updatedRow.row);
|
||||
}
|
||||
|
||||
final updatedIndexs =
|
||||
_rowList.updateRows(updatedRows, (rowPB) => buildGridRow(rowPB));
|
||||
_rowList.updateRows(rowPBs, (rowPB) => buildGridRow(rowPB));
|
||||
if (updatedIndexs.isNotEmpty) {
|
||||
_rowChangeReasonNotifier.receive(RowsChangedReason.update(updatedIndexs));
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class _PropertyList extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(child: _wrapScrollbar(buildList(state))),
|
||||
Expanded(child: _wrapScrollbar(buildRowCells(state))),
|
||||
const VSpace(10),
|
||||
_CreateFieldButton(
|
||||
viewId: viewId,
|
||||
@ -126,7 +126,7 @@ class _PropertyList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildList(RowDetailState state) {
|
||||
Widget buildRowCells(RowDetailState state) {
|
||||
return ListView.separated(
|
||||
controller: _scrollController,
|
||||
itemCount: state.gridCells.length,
|
||||
|
@ -160,6 +160,16 @@ impl std::convert::From<&RowRevision> for InsertedRowPB {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ProtoBuf)]
|
||||
pub struct UpdatedRowPB {
|
||||
#[pb(index = 1)]
|
||||
pub row: RowPB,
|
||||
|
||||
// represents as the cells that were updated in this row.
|
||||
#[pb(index = 2)]
|
||||
pub field_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, ProtoBuf)]
|
||||
pub struct GridBlockChangesetPB {
|
||||
#[pb(index = 1)]
|
||||
@ -172,7 +182,7 @@ pub struct GridBlockChangesetPB {
|
||||
pub deleted_rows: Vec<String>,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub updated_rows: Vec<RowPB>,
|
||||
pub updated_rows: Vec<UpdatedRowPB>,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub visible_rows: Vec<InsertedRowPB>,
|
||||
@ -197,7 +207,7 @@ impl GridBlockChangesetPB {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(block_id: &str, updated_rows: Vec<RowPB>) -> Self {
|
||||
pub fn update(block_id: &str, updated_rows: Vec<UpdatedRowPB>) -> Self {
|
||||
Self {
|
||||
block_id: block_id.to_owned(),
|
||||
updated_rows,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::dart_notification::{send_dart_notification, GridDartNotification};
|
||||
use crate::entities::{CellChangesetPB, GridBlockChangesetPB, InsertedRowPB, RowPB};
|
||||
use crate::entities::{CellChangesetPB, GridBlockChangesetPB, InsertedRowPB, RowPB, UpdatedRowPB};
|
||||
use crate::manager::GridUser;
|
||||
use crate::services::block_editor::{GridBlockRevisionCompress, GridBlockRevisionEditor};
|
||||
use crate::services::persistence::block_index::BlockIndexCache;
|
||||
@ -111,8 +111,12 @@ impl GridBlockManager {
|
||||
match editor.get_row_rev(&changeset.row_id).await? {
|
||||
None => tracing::error!("Update row failed, can't find the row with id: {}", changeset.row_id),
|
||||
Some((_, row_rev)) => {
|
||||
let row_pb = make_row_from_row_rev(row_rev);
|
||||
let block_order_changeset = GridBlockChangesetPB::update(&editor.block_id, vec![row_pb]);
|
||||
let changed_field_ids = changeset.cell_by_field_id.keys().cloned().collect::<Vec<String>>();
|
||||
let updated_row = UpdatedRowPB {
|
||||
row: make_row_from_row_rev(row_rev),
|
||||
field_ids: changed_field_ids,
|
||||
};
|
||||
let block_order_changeset = GridBlockChangesetPB::update(&editor.block_id, vec![updated_row]);
|
||||
let _ = self
|
||||
.notify_did_update_block(&editor.block_id, block_order_changeset)
|
||||
.await?;
|
||||
|
@ -46,6 +46,8 @@ pub struct RowChangeset {
|
||||
pub row_id: String,
|
||||
pub height: Option<i32>,
|
||||
pub visibility: Option<bool>,
|
||||
// Contains the key/value changes represents as the update of the cells. For example,
|
||||
// if there is one cell was changed, then the `cell_by_field_id` will only have one key/value.
|
||||
pub cell_by_field_id: HashMap<FieldId, CellRevision>,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user