Skip to content

Commit a896637

Browse files
committed
fix: reload card content
1 parent 82b44c2 commit a896637

File tree

8 files changed

+54
-32
lines changed

8 files changed

+54
-32
lines changed

frontend/app_flowy/lib/plugins/board/application/board_bloc.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {
317317

318318
@override
319319
void updateRow(String groupId, RowPB row) {
320-
controller.updateColumnItem(groupId, BoardColumnItem(row: row));
320+
// workaround: fix the board card reload timing issue.
321+
Future.delayed(const Duration(milliseconds: 300), () {
322+
controller.updateColumnItem(groupId, BoardColumnItem(row: row));
323+
});
321324
}
322325
}

frontend/app_flowy/lib/plugins/board/board.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BoardPluginBuilder implements PluginBuilder {
3131

3232
class BoardPluginConfig implements PluginConfig {
3333
@override
34-
bool get creatable => true;
34+
bool get creatable => false;
3535
}
3636

3737
class BoardPlugin extends Plugin {

frontend/app_flowy/lib/plugins/board/presentation/card/board_select_option_cell.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,17 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
3535
child: BlocBuilder<BoardSelectOptionCellBloc, BoardSelectOptionCellState>(
3636
builder: (context, state) {
3737
final children = state.selectedOptions
38-
.map((option) => SelectOptionTag.fromOption(
39-
context: context,
40-
option: option,
41-
))
38+
.map(
39+
(option) => SelectOptionTag.fromOption(
40+
context: context,
41+
option: option,
42+
),
43+
)
4244
.toList();
4345
return Align(
4446
alignment: Alignment.centerLeft,
4547
child: AbsorbPointer(
46-
child: Wrap(
47-
children: children,
48-
spacing: 4,
49-
runSpacing: 2,
50-
),
48+
child: Wrap(children: children, spacing: 4, runSpacing: 2),
5149
),
5250
);
5351
},

frontend/app_flowy/lib/plugins/board/presentation/card/card.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class _BoardCardState extends State<BoardCard> {
4242
_cardBloc = BoardCardBloc(
4343
gridId: widget.gridId,
4444
dataController: widget.dataController,
45-
);
45+
)..add(const BoardCardEvent.initial());
4646
super.initState();
4747
}
4848

@@ -79,6 +79,12 @@ class _BoardCardState extends State<BoardCard> {
7979
},
8080
).toList();
8181
}
82+
83+
@override
84+
Future<void> dispose() async {
85+
_cardBloc.close();
86+
super.dispose();
87+
}
8288
}
8389

8490
class _CardMoreOption extends StatelessWidget with CardAccessory {

frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_data_loader.dart

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ class GridCellDataLoader<T> {
2424
Future<T?> loadData() {
2525
final fut = service.getCell(cellId: cellId);
2626
return fut.then(
27-
(result) => result.fold((GridCellPB cell) {
28-
try {
29-
return parser.parserData(cell.data);
30-
} catch (e, s) {
31-
Log.error('$parser parser cellData failed, $e');
32-
Log.error('Stack trace \n $s');
27+
(result) => result.fold(
28+
(GridCellPB cell) {
29+
try {
30+
return parser.parserData(cell.data);
31+
} catch (e, s) {
32+
Log.error('$parser parser cellData failed, $e');
33+
Log.error('Stack trace \n $s');
34+
return null;
35+
}
36+
},
37+
(err) {
38+
Log.error(err);
3339
return null;
34-
}
35-
}, (err) {
36-
Log.error(err);
37-
return null;
38-
}),
40+
},
41+
),
3942
);
4043
}
4144
}
@@ -58,7 +61,8 @@ class DateCellDataParser implements IGridCellDataParser<DateCellDataPB> {
5861
}
5962
}
6063

61-
class SelectOptionCellDataParser implements IGridCellDataParser<SelectOptionCellDataPB> {
64+
class SelectOptionCellDataParser
65+
implements IGridCellDataParser<SelectOptionCellDataPB> {
6266
@override
6367
SelectOptionCellDataPB? parserData(List<int> data) {
6468
if (data.isEmpty) {

frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ class IGridCellController<T, D> extends Equatable {
279279
_loadDataOperation?.cancel();
280280
_loadDataOperation = Timer(const Duration(milliseconds: 10), () {
281281
_cellDataLoader.loadData().then((data) {
282-
_cellDataNotifier?.value = data;
282+
Log.debug('$fieldId CellData: Did Get cell data');
283283
_cellsCache.insert(_cacheKey, GridCell(object: data));
284+
_cellDataNotifier?.value = data;
284285
});
285286
});
286287
}

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column_data.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ class AFBoardColumnDataController extends ChangeNotifier with EquatableMixin {
133133
void replaceOrInsertItem(AFColumnItem newItem) {
134134
final index = columnData._items.indexWhere((item) => item.id == newItem.id);
135135
if (index != -1) {
136-
removeAt(index);
137-
138136
columnData._items.removeAt(index);
139137
columnData._items.insert(index, newItem);
140138
notifyListeners();

frontend/rust-lib/flowy-grid/src/services/grid_editor.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl GridRevisionEditor {
582582

583583
pub async fn move_group_row(&self, params: MoveGroupRowParams) -> FlowyResult<()> {
584584
let MoveGroupRowParams {
585-
view_id: _,
585+
view_id,
586586
from_row_id,
587587
to_group_id,
588588
to_row_id,
@@ -597,10 +597,22 @@ impl GridRevisionEditor {
597597
.await
598598
{
599599
tracing::trace!("Move group row cause row data changed: {:?}", row_changeset);
600-
match self.block_manager.update_row(row_changeset).await {
601-
Ok(_) => {}
602-
Err(e) => {
603-
tracing::error!("Apply row changeset error:{:?}", e);
600+
601+
let cell_changesets = row_changeset
602+
.cell_by_field_id
603+
.into_iter()
604+
.map(|(field_id, cell_rev)| CellChangesetPB {
605+
grid_id: view_id.clone(),
606+
row_id: row_changeset.row_id.clone(),
607+
field_id,
608+
content: cell_rev.data,
609+
})
610+
.collect::<Vec<CellChangesetPB>>();
611+
612+
for cell_changeset in cell_changesets {
613+
match self.block_manager.update_cell(cell_changeset).await {
614+
Ok(_) => {}
615+
Err(e) => tracing::error!("Apply cell changeset error:{:?}", e),
604616
}
605617
}
606618
}

0 commit comments

Comments
 (0)