mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: reload card content
This commit is contained in:
parent
82b44c2c98
commit
a896637eab
@ -317,6 +317,9 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {
|
||||
|
||||
@override
|
||||
void updateRow(String groupId, RowPB row) {
|
||||
controller.updateColumnItem(groupId, BoardColumnItem(row: row));
|
||||
// workaround: fix the board card reload timing issue.
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
controller.updateColumnItem(groupId, BoardColumnItem(row: row));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class BoardPluginBuilder implements PluginBuilder {
|
||||
|
||||
class BoardPluginConfig implements PluginConfig {
|
||||
@override
|
||||
bool get creatable => true;
|
||||
bool get creatable => false;
|
||||
}
|
||||
|
||||
class BoardPlugin extends Plugin {
|
||||
|
@ -35,19 +35,17 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
|
||||
child: BlocBuilder<BoardSelectOptionCellBloc, BoardSelectOptionCellState>(
|
||||
builder: (context, state) {
|
||||
final children = state.selectedOptions
|
||||
.map((option) => SelectOptionTag.fromOption(
|
||||
context: context,
|
||||
option: option,
|
||||
))
|
||||
.map(
|
||||
(option) => SelectOptionTag.fromOption(
|
||||
context: context,
|
||||
option: option,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: AbsorbPointer(
|
||||
child: Wrap(
|
||||
children: children,
|
||||
spacing: 4,
|
||||
runSpacing: 2,
|
||||
),
|
||||
child: Wrap(children: children, spacing: 4, runSpacing: 2),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ class _BoardCardState extends State<BoardCard> {
|
||||
_cardBloc = BoardCardBloc(
|
||||
gridId: widget.gridId,
|
||||
dataController: widget.dataController,
|
||||
);
|
||||
)..add(const BoardCardEvent.initial());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -79,6 +79,12 @@ class _BoardCardState extends State<BoardCard> {
|
||||
},
|
||||
).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
_cardBloc.close();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class _CardMoreOption extends StatelessWidget with CardAccessory {
|
||||
|
@ -24,18 +24,21 @@ class GridCellDataLoader<T> {
|
||||
Future<T?> loadData() {
|
||||
final fut = service.getCell(cellId: cellId);
|
||||
return fut.then(
|
||||
(result) => result.fold((GridCellPB cell) {
|
||||
try {
|
||||
return parser.parserData(cell.data);
|
||||
} catch (e, s) {
|
||||
Log.error('$parser parser cellData failed, $e');
|
||||
Log.error('Stack trace \n $s');
|
||||
(result) => result.fold(
|
||||
(GridCellPB cell) {
|
||||
try {
|
||||
return parser.parserData(cell.data);
|
||||
} catch (e, s) {
|
||||
Log.error('$parser parser cellData failed, $e');
|
||||
Log.error('Stack trace \n $s');
|
||||
return null;
|
||||
}
|
||||
},
|
||||
(err) {
|
||||
Log.error(err);
|
||||
return null;
|
||||
}
|
||||
}, (err) {
|
||||
Log.error(err);
|
||||
return null;
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -58,7 +61,8 @@ class DateCellDataParser implements IGridCellDataParser<DateCellDataPB> {
|
||||
}
|
||||
}
|
||||
|
||||
class SelectOptionCellDataParser implements IGridCellDataParser<SelectOptionCellDataPB> {
|
||||
class SelectOptionCellDataParser
|
||||
implements IGridCellDataParser<SelectOptionCellDataPB> {
|
||||
@override
|
||||
SelectOptionCellDataPB? parserData(List<int> data) {
|
||||
if (data.isEmpty) {
|
||||
|
@ -279,8 +279,9 @@ class IGridCellController<T, D> extends Equatable {
|
||||
_loadDataOperation?.cancel();
|
||||
_loadDataOperation = Timer(const Duration(milliseconds: 10), () {
|
||||
_cellDataLoader.loadData().then((data) {
|
||||
_cellDataNotifier?.value = data;
|
||||
Log.debug('$fieldId CellData: Did Get cell data');
|
||||
_cellsCache.insert(_cacheKey, GridCell(object: data));
|
||||
_cellDataNotifier?.value = data;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -133,8 +133,6 @@ class AFBoardColumnDataController extends ChangeNotifier with EquatableMixin {
|
||||
void replaceOrInsertItem(AFColumnItem newItem) {
|
||||
final index = columnData._items.indexWhere((item) => item.id == newItem.id);
|
||||
if (index != -1) {
|
||||
removeAt(index);
|
||||
|
||||
columnData._items.removeAt(index);
|
||||
columnData._items.insert(index, newItem);
|
||||
notifyListeners();
|
||||
|
@ -582,7 +582,7 @@ impl GridRevisionEditor {
|
||||
|
||||
pub async fn move_group_row(&self, params: MoveGroupRowParams) -> FlowyResult<()> {
|
||||
let MoveGroupRowParams {
|
||||
view_id: _,
|
||||
view_id,
|
||||
from_row_id,
|
||||
to_group_id,
|
||||
to_row_id,
|
||||
@ -597,10 +597,22 @@ impl GridRevisionEditor {
|
||||
.await
|
||||
{
|
||||
tracing::trace!("Move group row cause row data changed: {:?}", row_changeset);
|
||||
match self.block_manager.update_row(row_changeset).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
tracing::error!("Apply row changeset error:{:?}", e);
|
||||
|
||||
let cell_changesets = row_changeset
|
||||
.cell_by_field_id
|
||||
.into_iter()
|
||||
.map(|(field_id, cell_rev)| CellChangesetPB {
|
||||
grid_id: view_id.clone(),
|
||||
row_id: row_changeset.row_id.clone(),
|
||||
field_id,
|
||||
content: cell_rev.data,
|
||||
})
|
||||
.collect::<Vec<CellChangesetPB>>();
|
||||
|
||||
for cell_changeset in cell_changesets {
|
||||
match self.block_manager.update_cell(cell_changeset).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => tracing::error!("Apply cell changeset error:{:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user