From 3e4e8679ce82f5e2b055521b53aefb6f609d5e9c Mon Sep 17 00:00:00 2001 From: appflowy Date: Thu, 18 Aug 2022 15:38:55 +0800 Subject: [PATCH] fix: debounce causes save cell data fail --- .../grid/application/cell/select_option_editor_bloc.dart | 2 +- .../grid/application/cell/select_option_service.dart | 2 +- .../grid/presentation/widgets/cell/number_cell.dart | 9 +++------ .../grid/presentation/widgets/cell/text_cell.dart | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) 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 6ee7fe9f32..8d52252e2a 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 @@ -111,7 +111,7 @@ class SelectOptionCellEditorBloc void _loadOptions() { _delayOperation?.cancel(); _delayOperation = Timer(const Duration(milliseconds: 10), () { - _selectOptionService.getOpitonContext().then((result) { + _selectOptionService.getOptionContext().then((result) { if (isClosed) { return; } diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart index da1fc47170..44d4bdd4be 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/select_option_service.dart @@ -55,7 +55,7 @@ class SelectOptionService { return GridEventUpdateSelectOption(payload).send(); } - Future> getOpitonContext() { + Future> getOptionContext() { final payload = GridCellIdPB.create() ..gridId = gridId ..fieldId = fieldId 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 2926972f95..cd5151d750 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 @@ -65,6 +65,8 @@ class _NumberCellState extends GridFocusNodeCellState { @override Future dispose() async { + _delayOperation = null; + _cellBloc.close(); super.dispose(); } @@ -72,15 +74,10 @@ class _NumberCellState extends GridFocusNodeCellState { Future focusChanged() async { if (mounted) { _delayOperation?.cancel(); - _delayOperation = Timer(const Duration(milliseconds: 300), () { + _delayOperation = Timer(const Duration(milliseconds: 30), () { if (_cellBloc.isClosed == false && _controller.text != contentFromState(_cellBloc.state)) { _cellBloc.add(NumberCellEvent.updateCell(_controller.text)); - - if (!mounted) { - _delayOperation = null; - _cellBloc.close(); - } } }); } diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart index 04be48b9ea..0052ad5e70 100644 --- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart +++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/cell/text_cell.dart @@ -76,7 +76,7 @@ class _GridTextCellState extends GridFocusNodeCellState { @override Future dispose() async { - _delayOperation?.cancel(); + _delayOperation = null; _cellBloc.close(); super.dispose(); } @@ -85,7 +85,7 @@ class _GridTextCellState extends GridFocusNodeCellState { Future focusChanged() async { if (mounted) { _delayOperation?.cancel(); - _delayOperation = Timer(const Duration(milliseconds: 300), () { + _delayOperation = Timer(const Duration(milliseconds: 30), () { if (_cellBloc.isClosed == false && _controller.text != _cellBloc.state.content) { _cellBloc.add(TextCellEvent.updateText(_controller.text));