|
@@ -1,5 +1,6 @@
|
|
|
import 'package:app_flowy/workspace/application/grid/cell_bloc/cell_listener.dart';
|
|
|
import 'package:app_flowy/workspace/application/grid/cell_bloc/select_option_service.dart';
|
|
|
+import 'package:app_flowy/workspace/application/grid/field/field_listener.dart';
|
|
|
import 'package:app_flowy/workspace/application/grid/row/row_service.dart';
|
|
|
import 'package:flowy_sdk/log.dart';
|
|
|
import 'package:flowy_sdk/protobuf/flowy-grid/selection_type_option.pb.dart';
|
|
@@ -11,12 +12,14 @@ part 'selection_cell_bloc.freezed.dart';
|
|
|
|
|
|
class SelectionCellBloc extends Bloc<SelectionCellEvent, SelectionCellState> {
|
|
|
final SelectOptionService _service;
|
|
|
- final CellListener _listener;
|
|
|
+ final CellListener _cellListener;
|
|
|
+ final FieldListener _fieldListener;
|
|
|
|
|
|
SelectionCellBloc({
|
|
|
required CellData cellData,
|
|
|
}) : _service = SelectOptionService(),
|
|
|
- _listener = CellListener(rowId: cellData.rowId, fieldId: cellData.field.id),
|
|
|
+ _cellListener = CellListener(rowId: cellData.rowId, fieldId: cellData.field.id),
|
|
|
+ _fieldListener = FieldListener(fieldId: cellData.field.id),
|
|
|
super(SelectionCellState.initial(cellData)) {
|
|
|
on<SelectionCellEvent>(
|
|
|
(event, emit) async {
|
|
@@ -35,7 +38,8 @@ class SelectionCellBloc extends Bloc<SelectionCellEvent, SelectionCellState> {
|
|
|
|
|
|
@override
|
|
|
Future<void> close() async {
|
|
|
- await _listener.stop();
|
|
|
+ await _cellListener.stop();
|
|
|
+ await _fieldListener.stop();
|
|
|
return super.close();
|
|
|
}
|
|
|
|
|
@@ -56,13 +60,21 @@ class SelectionCellBloc extends Bloc<SelectionCellEvent, SelectionCellState> {
|
|
|
}
|
|
|
|
|
|
void _startListening() {
|
|
|
- _listener.updateCellNotifier.addPublishListener((result) {
|
|
|
+ _cellListener.updateCellNotifier.addPublishListener((result) {
|
|
|
result.fold(
|
|
|
(notificationData) => _loadOptions(),
|
|
|
(err) => Log.error(err),
|
|
|
);
|
|
|
});
|
|
|
- _listener.start();
|
|
|
+ _cellListener.start();
|
|
|
+
|
|
|
+ _fieldListener.updateFieldNotifier.addPublishListener((result) {
|
|
|
+ result.fold(
|
|
|
+ (field) => _loadOptions(),
|
|
|
+ (err) => Log.error(err),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ _fieldListener.start();
|
|
|
}
|
|
|
}
|
|
|
|