diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart index 5da5fce86d..4805ad8b7a 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart @@ -11,13 +11,15 @@ typedef UpdateFieldNotifiedValue = Either; class CellListener { final String rowId; final String fieldId; - PublishNotifier? _updateCellNotifier = PublishNotifier(); + PublishNotifier? _updateCellNotifier = + PublishNotifier(); GridNotificationListener? _listener; CellListener({required this.rowId, required this.fieldId}); void start({required void Function(UpdateFieldNotifiedValue) onCellChanged}) { _updateCellNotifier?.addPublishListener(onCellChanged); - _listener = GridNotificationListener(objectId: "$rowId:$fieldId", handler: _handler); + _listener = GridNotificationListener( + objectId: "$rowId:$fieldId", handler: _handler); } void _handler(GridNotification ty, Either result) { diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart index 1f14c7c54a..3d816b21d1 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/cell_cache.dart @@ -33,10 +33,17 @@ class GridCellCache { required this.gridId, }); - void remove(String fieldId) { + void removeCellWithFieldId(String fieldId) { _cellDataByFieldId.remove(fieldId); } + void remove(GridCellCacheKey key) { + var map = _cellDataByFieldId[key.fieldId]; + if (map != null) { + map.remove(key.rowId); + } + } + void insert(GridCellCacheKey key, T value) { var map = _cellDataByFieldId[key.fieldId]; if (map == null) { diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart index 8ab486a48c..d716133d05 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_service/context_builder.dart @@ -191,7 +191,7 @@ class IGridCellController extends Equatable { _cellListener?.start(onCellChanged: (result) { result.fold( (_) { - _cellsCache.remove(fieldId); + _cellsCache.remove(_cacheKey); _loadData(); }, (err) => Log.error(err), diff --git a/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart index 68c8b6f519..d6cd387e74 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart @@ -52,7 +52,8 @@ class GridRowCache { // notifier.onRowFieldsChanged(() => _rowChangeReasonNotifier .receive(const RowsChangedReason.fieldDidChange())); - notifier.onRowFieldChanged((field) => _cellCache.remove(field.id)); + notifier.onRowFieldChanged( + (field) => _cellCache.removeCellWithFieldId(field.id)); _rowInfos = block.rows.map((rowPB) => buildGridRow(rowPB)).toList(); }