ci: fix potential test fail (#1722)

This commit is contained in:
Nathan.fooo 2023-01-19 14:10:57 +08:00 committed by GitHub
parent 115bf20ce0
commit aeb29d2e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 50 deletions

View File

@ -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();

View File

@ -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));
}
}
}

View File

@ -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,