From 5878379b2eec742320f4a1a634a54e29fd409800 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 18 Aug 2024 18:44:32 +0800 Subject: [PATCH] chore: lazy load database row (#6001) * chore: fix potential load database rows fail * chore: fix layout padding --- .../row/related_row_detail_bloc.dart | 10 +-- .../database/application/row/row_cache.dart | 11 ++- .../application/row/row_controller.dart | 39 +++++++++-- .../calendar_event_editor_bloc.dart | 4 +- .../grid/application/row/row_bloc.dart | 6 +- .../grid/application/row/row_detail_bloc.dart | 4 +- .../database/grid/presentation/grid_page.dart | 66 ++++++++++-------- .../presentation/widgets/row/mobile_row.dart | 2 +- .../tab_bar/desktop/setting_menu.dart | 2 +- frontend/appflowy_tauri/src-tauri/Cargo.lock | 14 ++-- frontend/appflowy_tauri/src-tauri/Cargo.toml | 14 ++-- .../appflowy_web_app/src-tauri/Cargo.lock | 14 ++-- .../appflowy_web_app/src-tauri/Cargo.toml | 14 ++-- frontend/rust-lib/Cargo.lock | 14 ++-- frontend/rust-lib/Cargo.toml | 14 ++-- .../rust-lib/flowy-database2/src/manager.rs | 1 + .../src/services/database/database_editor.rs | 68 +++++++++++++------ .../src/services/database/database_observe.rs | 1 - .../src/services/database_view/view_editor.rs | 8 +-- .../src/services/database_view/view_filter.rs | 4 +- .../src/services/database_view/view_group.rs | 2 +- .../services/database_view/view_operation.rs | 4 +- .../src/services/database_view/view_sort.rs | 2 +- .../tests/database/database_editor.rs | 4 +- .../tests/database/field_test/script.rs | 2 +- .../database/pre_fill_cell_test/script.rs | 8 +-- .../tests/database/share_test/export_test.rs | 4 +- .../tests/database/sort_test/script.rs | 2 +- 28 files changed, 204 insertions(+), 134 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/row/related_row_detail_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/application/row/related_row_detail_bloc.dart index 06e1e2b70f..1390d9ff97 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/application/row/related_row_detail_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/application/row/related_row_detail_bloc.dart @@ -23,9 +23,9 @@ class RelatedRowDetailPageBloc @override Future close() { state.whenOrNull( - ready: (databaseController, rowController) { - rowController.dispose(); - databaseController.dispose(); + ready: (databaseController, rowController) async { + await rowController.dispose(); + await databaseController.dispose(); }, ); return super.close(); @@ -36,8 +36,8 @@ class RelatedRowDetailPageBloc event.when( didInitialize: (databaseController, rowController) { state.maybeWhen( - ready: (_, oldRowController) { - oldRowController.dispose(); + ready: (_, oldRowController) async { + await oldRowController.dispose(); emit( RelatedRowDetailPageState.ready( databaseController: databaseController, diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart index 90f20b2fe7..6f4d886f80 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_cache.dart @@ -81,6 +81,12 @@ class RowCache { _changedNotifier.receive(const ChangedReason.setInitialRows()); } + void setRowMeta(RowMetaPB rowMeta) { + final rowInfo = buildGridRow(rowMeta); + _rowList.add(rowInfo); + _changedNotifier.receive(const ChangedReason.didFetchRow()); + } + void dispose() { _rowLifeCycle.onRowDisposed(); _changedNotifier.dispose(); @@ -215,7 +221,8 @@ class RowCache { if (rowInfo == null) { _loadRow(rowMeta.id); } - return _makeCells(rowMeta); + final cells = _makeCells(rowMeta); + return cells; } Future _loadRow(RowId rowId) async { @@ -277,6 +284,7 @@ class RowChangesetNotifier extends ChangeNotifier { reorderRows: (_) => notifyListeners(), reorderSingleRow: (_) => notifyListeners(), setInitialRows: (_) => notifyListeners(), + didFetchRow: (_) => notifyListeners(), ); } } @@ -305,6 +313,7 @@ class ChangedReason with _$ChangedReason { const factory ChangedReason.update(UpdatedIndexMap indexs) = _Update; const factory ChangedReason.fieldDidChange() = _FieldDidChange; const factory ChangedReason.initial() = InitialListState; + const factory ChangedReason.didFetchRow() = _DidFetchRow; const factory ChangedReason.reorderRows() = _ReorderRows; const factory ChangedReason.reorderSingleRow( ReorderSingleRowPB reorderRow, diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_controller.dart b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_controller.dart index b34beba275..a52bd66199 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/application/row/row_controller.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/application/row/row_controller.dart @@ -1,3 +1,5 @@ +import 'package:appflowy/plugins/database/application/row/row_service.dart'; +import 'package:appflowy/plugins/database/domain/row_listener.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart'; import 'package:flutter/material.dart'; @@ -9,35 +11,60 @@ typedef OnRowChanged = void Function(List, ChangedReason); class RowController { RowController({ - required this.rowMeta, + required RowMetaPB rowMeta, required this.viewId, required RowCache rowCache, this.groupId, - }) : _rowCache = rowCache; + }) : _rowMeta = rowMeta, + _rowCache = rowCache, + _rowBackendSvc = RowBackendService(viewId: viewId), + _rowListener = RowListener(rowMeta.id) { + _rowBackendSvc.initRow(rowMeta.id); + _rowListener.start( + onMetaChanged: (newRowMeta) { + if (_isDisposed) { + return; + } + _rowMeta = newRowMeta; + _rowCache.setRowMeta(newRowMeta); + }, + ); + } - final RowMetaPB rowMeta; + RowMetaPB _rowMeta; final String? groupId; final String viewId; final List _onRowChangedListeners = []; final RowCache _rowCache; + final RowListener _rowListener; + final RowBackendService _rowBackendSvc; + bool _isDisposed = false; CellMemCache get cellCache => _rowCache.cellCache; String get rowId => rowMeta.id; + RowMetaPB get rowMeta => _rowMeta; - List loadData() => _rowCache.loadCells(rowMeta); + List loadCells() => _rowCache.loadCells(rowMeta); void addListener({OnRowChanged? onRowChanged}) { final fn = _rowCache.addListener( rowId: rowMeta.id, - onRowChanged: onRowChanged, + onRowChanged: (context, reasons) { + if (_isDisposed) { + return; + } + onRowChanged?.call(context, reasons); + }, ); // Add the listener to the list so that we can remove it later. _onRowChangedListeners.add(fn); } - void dispose() { + Future dispose() async { + _isDisposed = true; + await _rowListener.stop(); for (final fn in _onRowChangedListeners) { _rowCache.removeRowListener(fn); } diff --git a/frontend/appflowy_flutter/lib/plugins/database/calendar/application/calendar_event_editor_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/calendar/application/calendar_event_editor_bloc.dart index 303daff87e..b122d951be 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/calendar/application/calendar_event_editor_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/calendar/application/calendar_event_editor_bloc.dart @@ -34,7 +34,7 @@ class CalendarEventEditorBloc .firstWhere((fieldInfo) => fieldInfo.isPrimary) .id; final cells = rowController - .loadData() + .loadCells() .where( (cellContext) => _filterCellContext(cellContext, primaryFieldId), @@ -88,7 +88,7 @@ class CalendarEventEditorBloc @override Future close() async { - rowController.dispose(); + await rowController.dispose(); return super.close(); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_bloc.dart index 322d7d59a4..69feda410c 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_bloc.dart @@ -23,8 +23,6 @@ class RowBloc extends Bloc { }) : _rowBackendSvc = RowBackendService(viewId: viewId), _rowController = rowController, super(RowState.initial()) { - _rowBackendSvc.initRow(rowId); - _dispatch(); _startListening(); _init(); @@ -38,7 +36,7 @@ class RowBloc extends Bloc { @override Future close() async { - _rowController.dispose(); + await _rowController.dispose(); return super.close(); } @@ -84,7 +82,7 @@ class RowBloc extends Bloc { void _init() { add( RowEvent.didReceiveCells( - _rowController.loadData(), + _rowController.loadCells(), const ChangedReason.setInitialRows(), ), ); diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_detail_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_detail_bloc.dart index 0d655a840b..5c25fc851f 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_detail_bloc.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/grid/application/row/row_detail_bloc.dart @@ -29,7 +29,7 @@ class RowDetailBloc extends Bloc { @override Future close() async { - rowController.dispose(); + await rowController.dispose(); return super.close(); } @@ -125,7 +125,7 @@ class RowDetailBloc extends Bloc { } void _init() { - allCells.addAll(rowController.loadData()); + allCells.addAll(rowController.loadCells()); int numHiddenFields = 0; final visibleCells = []; for (final cell in allCells) { diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart index 50b67e7a8f..b2e873e67e 100755 --- a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart @@ -9,7 +9,6 @@ import 'package:appflowy/workspace/application/action_navigation/navigation_acti import 'package:appflowy/workspace/application/view/view_bloc.dart'; import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; -import 'package:collection/collection.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart'; @@ -154,6 +153,7 @@ class _GridPageState extends State { finish: (result) => result.successOrFail.fold( (_) => GridShortcuts( child: GridPageContent( + key: ValueKey(widget.view.id), view: widget.view, ), ), @@ -331,33 +331,10 @@ class _GridRowsState extends State<_GridRows> { BuildContext context, GridState state, ) { - final children = state.rowInfos.mapIndexed((index, rowInfo) { - return _renderRow( - context, - rowInfo.rowId, - isDraggable: state.reorderable, - index: index, - ); - }).toList() - ..add(const GridRowBottomBar(key: Key('grid_footer'))); - - if (showFloatingCalculations) { - children.add( - const SizedBox( - key: Key('calculations_bottom_padding'), - height: 36, - ), - ); - } else { - children.add( - GridCalculationsRow( - key: const Key('grid_calculations'), - viewId: widget.viewId, - ), - ); - } - - children.add(const SizedBox(key: Key('footer_padding'), height: 10)); + // 1. GridRowBottomBar + // 2. GridCalculationsRow + // 3. Footer Padding + final itemCount = state.rowInfos.length + 3; return Stack( children: [ @@ -381,8 +358,37 @@ class _GridRowsState extends State<_GridRows> { .add(GridEvent.moveRow(fromIndex, toIndex)); } }, - itemCount: children.length, - itemBuilder: (context, index) => children[index], + itemCount: itemCount, + itemBuilder: (context, index) { + if (index < state.rowInfos.length) { + return _renderRow( + context, + state.rowInfos[index].rowId, + isDraggable: state.reorderable, + index: index, + ); + } + + if (index == state.rowInfos.length) { + return const GridRowBottomBar(key: Key('grid_footer')); + } + + if (index == state.rowInfos.length + 1) { + if (showFloatingCalculations) { + return const SizedBox( + key: Key('calculations_bottom_padding'), + height: 36, + ); + } else { + return GridCalculationsRow( + key: const Key('grid_calculations'), + viewId: widget.viewId, + ); + } + } + + return const SizedBox(key: Key('footer_padding'), height: 10); + }, ), ), if (showFloatingCalculations) ...[ diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/row/mobile_row.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/row/mobile_row.dart index b6817fc848..f4e9d0c751 100755 --- a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/row/mobile_row.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/widgets/row/mobile_row.dart @@ -81,7 +81,7 @@ class _MobileGridRowState extends State { @override Future dispose() async { - _rowController.dispose(); + await _rowController.dispose(); super.dispose(); } } diff --git a/frontend/appflowy_flutter/lib/plugins/database/tab_bar/desktop/setting_menu.dart b/frontend/appflowy_flutter/lib/plugins/database/tab_bar/desktop/setting_menu.dart index 5b66c3a149..ad08d6b8e2 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/tab_bar/desktop/setting_menu.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/tab_bar/desktop/setting_menu.dart @@ -57,7 +57,7 @@ class _DatabaseViewSettingContent extends StatelessWidget { builder: (context, state) { return Padding( padding: EdgeInsets.symmetric( - horizontal: GridSize.horizontalHeaderPadding, + horizontal: GridSize.horizontalHeaderPadding + 40, ), child: DecoratedBox( decoration: BoxDecoration( diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock index 816bc62b34..0beeb29db6 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.lock +++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -988,7 +988,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-trait", @@ -1018,7 +1018,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -1038,7 +1038,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "bytes", @@ -1057,7 +1057,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-stream", @@ -1180,7 +1180,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index eba3aa40de..5f8c9e4117 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock index 6a6d842bf7..ddb1a8fd54 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.lock +++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock @@ -946,7 +946,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-trait", @@ -1001,7 +1001,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -1021,7 +1021,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "bytes", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -1083,7 +1083,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-stream", @@ -1163,7 +1163,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml index b3d45657bc..66de0bbd84 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.toml +++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 4f8ce47d41..95748a558c 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -824,7 +824,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -849,7 +849,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-trait", @@ -879,7 +879,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -899,7 +899,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "bytes", @@ -918,7 +918,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "arc-swap", @@ -961,7 +961,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "async-stream", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d03bd474e551ab5583780abe051a85b8063e6aa9#d03bd474e551ab5583780abe051a85b8063e6aa9" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" dependencies = [ "anyhow", "collab", diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index da234b004e..163aafd05e 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120 # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d03bd474e551ab5583780abe051a85b8063e6aa9" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index c37321fc92..7bce35e053 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -279,6 +279,7 @@ impl DatabaseManager { self.open_database(database_id).await } + #[instrument(level = "trace", skip_all, err)] pub async fn open_database(&self, database_id: &str) -> FlowyResult> { trace!("open database editor:{}", database_id); let lock = self.workspace_database()?; diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs index bf913db50c..35a82e3578 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs @@ -37,7 +37,7 @@ use lib_infra::util::timestamp; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::{broadcast, RwLock}; -use tracing::{error, event, instrument, trace, warn}; +use tracing::{debug, error, event, instrument, trace, warn}; #[derive(Clone)] pub struct DatabaseEditor { @@ -66,7 +66,7 @@ impl DatabaseEditor { // observe_view_change(&database_id, &database).await; // observe_field_change(&database_id, &database).await; observe_rows_change(&database_id, &database, ¬ification_sender).await; - // observe_block_event(&database_id, &database).await; + observe_block_event(&database_id, &database).await; // Used to cache the view of the database for fast access. let editor_by_view_id = Arc::new(RwLock::new(EditorByViewId::default())); @@ -119,7 +119,7 @@ impl DatabaseEditor { .database .read() .await - .get_database_rows() + .get_all_row_orders() .await .into_iter() .map(|entry| entry.id) @@ -509,16 +509,28 @@ impl DatabaseEditor { .ok_or_else(|| FlowyError::internal().with_context("error while copying row"))?; let (index, row_order) = database.create_row_in_view(view_id, params); - tracing::trace!("duplicated row: {:?} at {}", row_order, index); + trace!( + "duplicate row: {:?} at index:{}, new row:{:?}", + row_id, + index, + row_order + ); let row_detail = database.get_row_detail(&row_order.id).await; - (row_detail, index) }; - if let Some(row_detail) = row_detail { - for view in self.database_views.editors().await { - view.v_did_create_row(&row_detail, index).await; - } + match row_detail { + None => { + error!( + "Failed to duplicate row: {:?}. Row is not exist before duplicating", + row_id + ); + }, + Some(row_detail) => { + for view in self.database_views.editors().await { + view.v_did_create_row(&row_detail, index).await; + } + }, } Ok(()) @@ -654,9 +666,9 @@ impl DatabaseEditor { Ok(()) } - pub async fn get_rows(&self, view_id: &str) -> FlowyResult>> { + pub async fn get_row_details(&self, view_id: &str) -> FlowyResult>> { let view_editor = self.database_views.get_view_editor(view_id).await?; - Ok(view_editor.v_get_rows().await) + Ok(view_editor.v_get_row_details().await) } pub async fn get_row(&self, view_id: &str, row_id: &RowId) -> Option { @@ -669,11 +681,22 @@ impl DatabaseEditor { } pub async fn init_database_row(&self, row_id: &RowId) -> FlowyResult<()> { + if self + .database + .read() + .await + .get_database_row(row_id) + .is_some() + { + return Ok(()); + } + + debug!("Init database row: {}", row_id); let database_row = self .database .read() .await - .get_row_collab(row_id) + .create_database_row(row_id) .ok_or_else(|| { FlowyError::record_not_found() .with_context(format!("The row:{} in database not found", row_id)) @@ -1143,7 +1166,7 @@ impl DatabaseEditor { let to_row = if to_row.is_some() { to_row } else { - let row_details = self.get_rows(view_id).await?; + let row_details = self.get_row_details(view_id).await?; row_details .last() .map(|row_detail| row_detail.row.id.clone()) @@ -1275,7 +1298,8 @@ impl DatabaseEditor { .v_get_view() .await .ok_or_else(FlowyError::record_not_found)?; - let rows = database_view.v_get_rows().await; + + let row_orders = self.database.read().await.get_row_orders_for_view(&view_id); let (database_id, fields, is_linked) = { let database = self.database.read().await; let database_id = database.get_database_id(); @@ -1288,9 +1312,15 @@ impl DatabaseEditor { (database_id, fields, is_linked) }; - let rows = rows + let rows = row_orders .into_iter() - .map(|row_detail| RowMetaPB::from(row_detail.as_ref())) + .map(|row_order| RowMetaPB { + id: row_order.id.to_string(), + document_id: "".to_string(), + icon: None, + cover: None, + is_document_empty: false, + }) .collect::>(); Ok(DatabasePB { id: database_id, @@ -1374,7 +1404,7 @@ impl DatabaseEditor { .ok_or(FlowyError::internal())?; let row_data = { - let mut rows = database.get_database_rows().await; + let mut rows = database.get_all_rows().await; if let Some(row_ids) = row_ids { rows.retain(|row| row_ids.contains(&row.id)); } @@ -1504,7 +1534,7 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl { self.database.read().await.index_of_row(view_id, row_id) } - async fn get_row(&self, view_id: &str, row_id: &RowId) -> Option<(usize, Arc)> { + async fn get_row_detail(&self, view_id: &str, row_id: &RowId) -> Option<(usize, Arc)> { let database = self.database.read().await; let index = database.index_of_row(view_id, row_id); let row_detail = database.get_row_detail(row_id).await; @@ -1514,7 +1544,7 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl { } } - async fn get_rows(&self, view_id: &str) -> Vec> { + async fn get_row_details(&self, view_id: &str) -> Vec> { let view_id = view_id.to_string(); let row_orders = self.database.read().await.get_row_orders_for_view(&view_id); trace!("total row orders: {}", row_orders.len()); diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs index b25d365ab0..164c7c30fb 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs @@ -136,7 +136,6 @@ pub(crate) async fn observe_view_change(database_id: &str, database: &Arc>) { let database_id = database_id.to_string(); let weak_database = Arc::downgrade(database); diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs index aafc78e10e..f9377c1868 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs @@ -314,8 +314,8 @@ impl DatabaseViewEditor { } #[instrument(level = "info", skip(self))] - pub async fn v_get_rows(&self) -> Vec> { - let mut rows = self.delegate.get_rows(&self.view_id).await; + pub async fn v_get_row_details(&self) -> Vec> { + let mut rows = self.delegate.get_row_details(&self.view_id).await; self.v_filter_rows(&mut rows).await; self.v_sort_rows(&mut rows).await; rows @@ -937,7 +937,7 @@ impl DatabaseViewEditor { .timestamp .unwrap_or_default(); - let (_, row_detail) = self.delegate.get_row(&self.view_id, &row_id).await?; + let (_, row_detail) = self.delegate.get_row_detail(&self.view_id, &row_id).await?; Some(CalendarEventPB { row_meta: RowMetaPB::from(row_detail.as_ref()), date_field_id: date_field.id.clone(), @@ -1000,7 +1000,7 @@ impl DatabaseViewEditor { .unwrap_or_default() .into(); - let (_, row_detail) = self.delegate.get_row(&self.view_id, &row_id).await?; + let (_, row_detail) = self.delegate.get_row_detail(&self.view_id, &row_id).await?; let event = CalendarEventPB { row_meta: RowMetaPB::from(row_detail.as_ref()), date_field_id: calendar_setting.field_id.clone(), diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_filter.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_filter.rs index 994041aea9..33d4a40e87 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_filter.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_filter.rs @@ -53,11 +53,11 @@ impl FilterDelegate for DatabaseViewFilterDelegateImpl { } async fn get_rows(&self, view_id: &str) -> Vec> { - self.0.get_rows(view_id).await + self.0.get_row_details(view_id).await } async fn get_row(&self, view_id: &str, rows_id: &RowId) -> Option<(usize, Arc)> { - self.0.get_row(view_id, rows_id).await + self.0.get_row_detail(view_id, rows_id).await } async fn get_all_filters(&self, view_id: &str) -> Vec { diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs index b180904d6e..56c81eb183 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_group.rs @@ -97,7 +97,7 @@ impl GroupControllerDelegate for GroupControllerDelegateImpl { } async fn get_all_rows(&self, view_id: &str) -> Vec> { - let mut row_details = self.delegate.get_rows(view_id).await; + let mut row_details = self.delegate.get_row_details(view_id).await; self.filter_controller.filter_rows(&mut row_details).await; row_details } diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs index 4681566ebd..95c092702e 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_operation.rs @@ -53,10 +53,10 @@ pub trait DatabaseViewOperation: Send + Sync + 'static { async fn index_of_row(&self, view_id: &str, row_id: &RowId) -> Option; /// Returns the `index` and `RowRevision` with row_id - async fn get_row(&self, view_id: &str, row_id: &RowId) -> Option<(usize, Arc)>; + async fn get_row_detail(&self, view_id: &str, row_id: &RowId) -> Option<(usize, Arc)>; /// Returns all the rows in the view - async fn get_rows(&self, view_id: &str) -> Vec>; + async fn get_row_details(&self, view_id: &str) -> Vec>; async fn remove_row(&self, row_id: &RowId) -> Option; diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_sort.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_sort.rs index a719590e09..5491997eb4 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_sort.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_sort.rs @@ -61,7 +61,7 @@ impl SortDelegate for DatabaseViewSortDelegateImpl { async fn get_rows(&self, view_id: &str) -> Vec> { let view_id = view_id.to_string(); - let mut row_details = self.delegate.get_rows(&view_id).await; + let mut row_details = self.delegate.get_row_details(&view_id).await; self.filter_controller.filter_rows(&mut row_details).await; row_details } diff --git a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs index c18fef66a2..5086ce451c 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs @@ -86,7 +86,7 @@ impl DatabaseEditorTest { .map(Arc::new) .collect(); let rows = editor - .get_rows(&test.child_view.id) + .get_row_details(&test.child_view.id) .await .unwrap() .into_iter() @@ -109,7 +109,7 @@ impl DatabaseEditorTest { } pub async fn get_rows(&self) -> Vec> { - self.editor.get_rows(&self.view_id).await.unwrap() + self.editor.get_row_details(&self.view_id).await.unwrap() } pub async fn get_field(&self, field_id: &str, field_type: FieldType) -> Field { diff --git a/frontend/rust-lib/flowy-database2/tests/database/field_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/field_test/script.rs index bf93c130f8..f422cbdc72 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/field_test/script.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/field_test/script.rs @@ -121,7 +121,7 @@ impl DatabaseFieldTest { } => { let field = self.editor.get_field(&field_id).await.unwrap(); - let rows = self.editor.get_rows(&self.view_id()).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id()).await.unwrap(); let row_detail = rows.get(row_index).unwrap(); let cell = row_detail.row.cells.get(&field_id).unwrap().clone(); diff --git a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs index 6b524fdf15..f8f7d2f6ca 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs @@ -86,7 +86,7 @@ impl DatabasePreFillRowCellTest { .await .unwrap(), PreFillRowCellTestScript::AssertRowCount(expected_row_count) => { - let rows = self.editor.get_rows(&self.view_id).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id).await.unwrap(); assert_eq!(expected_row_count, rows.len()); }, PreFillRowCellTestScript::AssertCellExistence { @@ -94,7 +94,7 @@ impl DatabasePreFillRowCellTest { row_index, exists, } => { - let rows = self.editor.get_rows(&self.view_id).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id).await.unwrap(); let row_detail = rows.get(row_index).unwrap(); let cell = row_detail.row.cells.get(&field_id).cloned(); @@ -108,7 +108,7 @@ impl DatabasePreFillRowCellTest { } => { let field = self.editor.get_field(&field_id).await.unwrap(); - let rows = self.editor.get_rows(&self.view_id).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id).await.unwrap(); let row_detail = rows.get(row_index).unwrap(); let cell = row_detail @@ -125,7 +125,7 @@ impl DatabasePreFillRowCellTest { row_index, expected_content, } => { - let rows = self.editor.get_rows(&self.view_id).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id).await.unwrap(); let row_detail = rows.get(row_index).unwrap(); let cell = row_detail diff --git a/frontend/rust-lib/flowy-database2/tests/database/share_test/export_test.rs b/frontend/rust-lib/flowy-database2/tests/database/share_test/export_test.rs index 02f4f135ca..c23abb7d1d 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/share_test/export_test.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/share_test/export_test.rs @@ -33,7 +33,7 @@ async fn export_and_then_import_meta_csv_test() { let database = test.get_database(&result.database_id).await.unwrap(); let fields = database.get_fields(&result.view_id, None).await; - let rows = database.get_rows(&result.view_id).await.unwrap(); + let rows = database.get_row_details(&result.view_id).await.unwrap(); assert_eq!(fields[0].field_type, 0); assert_eq!(fields[1].field_type, 1); assert_eq!(fields[2].field_type, 2); @@ -112,7 +112,7 @@ async fn history_database_import_test() { let database = test.get_database(&result.database_id).await.unwrap(); let fields = database.get_fields(&result.view_id, None).await; - let rows = database.get_rows(&result.view_id).await.unwrap(); + let rows = database.get_row_details(&result.view_id).await.unwrap(); assert_eq!(fields[0].field_type, 0); assert_eq!(fields[1].field_type, 1); assert_eq!(fields[2].field_type, 2); diff --git a/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs index e95deaa187..956d62d727 100644 --- a/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs +++ b/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs @@ -117,7 +117,7 @@ impl DatabaseSortTest { }, SortScript::AssertCellContentOrder { field_id, orders } => { let mut cells = vec![]; - let rows = self.editor.get_rows(&self.view_id).await.unwrap(); + let rows = self.editor.get_row_details(&self.view_id).await.unwrap(); let field = self.editor.get_field(&field_id).await.unwrap(); for row_detail in rows { if let Some(cell) = row_detail.row.cells.get(&field_id) {