Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

ci: fix potential test fail (#1722)

Nathan.foooaeb29d2e4226
diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart
index 62b6f48423..de00ab3387 100644
--- a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart
+++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart
@@ -13,7 +13,6 @@ class SelectOptionCellEditorBloc
extends Bloc<SelectOptionEditorEvent, SelectOptionEditorState> {
final SelectOptionFFIService _selectOptionService;
final GridSelectOptionCellController cellController;
- Timer? _delayOperation;
SelectOptionCellEditorBloc({
required this.cellController,
@@ -25,7 +24,7 @@ class SelectOptionCellEditorBloc
await event.map(
initial: (_Initial value) async {
_startListening();
- _loadOptions();
+ await _loadOptions();
},
didReceiveOptions: (_DidReceiveOptions value) {
final result = _makeOptions(state.filter, value.options);
@@ -36,28 +35,28 @@ class SelectOptionCellEditorBloc
selectedOptions: value.selectedOptions,
));
},
- newOption: (_NewOption value) {
- _createOption(value.optionName);
+ newOption: (_NewOption value) async {
+ await _createOption(value.optionName);
emit(state.copyWith(
filter: none(),
));
},
- deleteOption: (_DeleteOption value) {
- _deleteOption([value.option]);
+ deleteOption: (_DeleteOption value) async {
+ await _deleteOption([value.option]);
},
- deleteAllOptions: (_DeleteAllOptions value) {
+ deleteAllOptions: (_DeleteAllOptions value) async {
if (state.allOptions.isNotEmpty) {
- _deleteOption(state.allOptions);
+ await _deleteOption(state.allOptions);
}
},
- updateOption: (_UpdateOption value) {
- _updateOption(value.option);
+ updateOption: (_UpdateOption value) async {
+ await _updateOption(value.option);
},
- selectOption: (_SelectOption value) {
- _selectOptionService.select(optionIds: [value.optionId]);
+ selectOption: (_SelectOption value) async {
+ await _selectOptionService.select(optionIds: [value.optionId]);
},
- unSelectOption: (_UnSelectOption value) {
- _selectOptionService.unSelect(optionIds: [value.optionId]);
+ unSelectOption: (_UnSelectOption value) async {
+ await _selectOptionService.unSelect(optionIds: [value.optionId]);
},
trySelectOption: (_TrySelectOption value) {
_trySelectOption(value.optionName, emit);
@@ -78,22 +77,21 @@ class SelectOptionCellEditorBloc
@override
Future<void> close() async {
- _delayOperation?.cancel();
await cellController.dispose();
return super.close();
}
- void _createOption(String name) async {
+ Future<void> _createOption(String name) async {
final result = await _selectOptionService.create(name: name);
result.fold((l) => {}, (err) => Log.error(err));
}
- void _deleteOption(List<SelectOptionPB> options) async {
+ Future<void> _deleteOption(List<SelectOptionPB> options) async {
final result = await _selectOptionService.delete(options: options);
result.fold((l) => null, (err) => Log.error(err));
}
- void _updateOption(SelectOptionPB option) async {
+ Future<void> _updateOption(SelectOptionPB option) async {
final result = await _selectOptionService.update(
option: option,
);
@@ -158,25 +156,24 @@ class SelectOptionCellEditorBloc
));
}
- void _loadOptions() {
- _delayOperation?.cancel();
- _delayOperation = Timer(const Duration(milliseconds: 10), () {
- _selectOptionService.getOptionContext().then((result) {
- if (isClosed) {
- return;
- }
- return result.fold(
- (data) => add(
- SelectOptionEditorEvent.didReceiveOptions(
- data.options, data.selectOptions),
- ),
- (err) {
- Log.error(err);
- return null;
- },
- );
- });
- });
+ Future<void> _loadOptions() async {
+ final result = await _selectOptionService.getOptionContext();
+ if (isClosed) {
+ return;
+ }
+
+ return result.fold(
+ (data) => add(
+ SelectOptionEditorEvent.didReceiveOptions(
+ data.options,
+ data.selectOptions,
+ ),
+ ),
+ (err) {
+ Log.error(err);
+ return null;
+ },
+ );
}
_MakeOptionResult _makeOptions(
@@ -210,9 +207,7 @@ class SelectOptionCellEditorBloc
void _startListening() {
cellController.startListening(
onCellChanged: ((selectOptionContext) {
- if (!isClosed) {
- _loadOptions();
- }
+ _loadOptions();
}),
onCellFieldChanged: () {
_loadOptions();
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart
index c7141a43b3..53badd13b0 100644
--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart
+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/number_cell.dart
@@ -22,7 +22,6 @@ class GridNumberCell extends GridCellWidget {
class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
late NumberCellBloc _cellBloc;
late TextEditingController _controller;
- Timer? _delayOperation;
@override
void initState() {
@@ -67,7 +66,6 @@ class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
@override
Future<void> dispose() async {
- _delayOperation = null;
_cellBloc.close();
super.dispose();
}
@@ -75,13 +73,10 @@ class _NumberCellState extends GridFocusNodeCellState<GridNumberCell> {
@override
Future<void> focusChanged() async {
if (mounted) {
- _delayOperation?.cancel();
- _delayOperation = Timer(const Duration(milliseconds: 30), () {
- if (_cellBloc.isClosed == false &&
- _controller.text != _cellBloc.state.cellContent) {
- _cellBloc.add(NumberCellEvent.updateCell(_controller.text));
- }
- });
+ if (_cellBloc.isClosed == false &&
+ _controller.text != _cellBloc.state.cellContent) {
+ _cellBloc.add(NumberCellEvent.updateCell(_controller.text));
+ }
}
}
diff --git a/frontend/rust-lib/flowy-revision/src/rev_manager.rs b/frontend/rust-lib/flowy-revision/src/rev_manager.rs
index 9e5e145857..23cc994ca3 100644
--- a/frontend/rust-lib/flowy-revision/src/rev_manager.rs
+++ b/frontend/rust-lib/flowy-revision/src/rev_manager.rs
@@ -127,7 +127,7 @@ impl<Connection: 'static> RevisionManager<Connection> {
}
}
- #[tracing::instrument(name = "revision_manager_initialize", level = "info", skip_all, fields(deserializer, object_id, deserialize_revisions) err)]
+ #[tracing::instrument(name = "revision_manager_initialize", level = "debug", skip_all, fields(deserializer, object_id, deserialize_revisions) err)]
pub async fn initialize<B>(&mut self, _cloud: Option<Arc<dyn RevisionCloudService>>) -> FlowyResult<B::Output>
where
B: RevisionObjectDeserializer,