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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
Feat/tauri build (#2378)
Nathan.fooo2838cd5e0cf0
diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yamlindex eae3e2c4ae..1fc9414804 100644--- a/.github/workflows/flutter_ci.yaml+++ b/.github/workflows/flutter_ci.yaml@@ -4,6 +4,7 @@ on:push:branches:- "main"+ - "develop"- "release/*"paths:- "frontend/**"@@ -11,6 +12,7 @@ on:pull_request:branches:- "main"+ - "develop"- "release/*"paths:- "frontend/**"diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yamlindex 33b08bbde7..fe4a1e9cb3 100644--- a/.github/workflows/rust_ci.yaml+++ b/.github/workflows/rust_ci.yaml@@ -4,6 +4,7 @@ on:push:branches:- "main"+ - "develop"- "release/*"paths:- "frontend/rust-lib/**"@@ -12,6 +13,7 @@ on:pull_request:branches:- "main"+ - "develop"- "release/*"paths:- "frontend/rust-lib/**"diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_cache.dartindex 19eb9d85ec..0955559ce4 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_cache.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_cache.dart@@ -13,7 +13,7 @@ class DatabaseCell {/// We use [fieldId + rowId] to identify the cell.class CellCacheKey {final String fieldId;- final Int64 rowId;+ final RowId rowId;CellCacheKey({required this.fieldId,required this.rowId,@@ -28,7 +28,7 @@ class CellCache {final String viewId;/// fieldId: {cacheKey: GridCell}- final Map<String, Map<Int64, dynamic>> _cellDataByFieldId = {};+ final Map<String, Map<RowId, dynamic>> _cellDataByFieldId = {};CellCache({required this.viewId,});diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dartindex 747af37461..074db88fcb 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_controller.dart@@ -1,11 +1,11 @@import 'dart:async';import 'package:appflowy/plugins/database_view/application/field/field_listener.dart';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:dartz/dartz.dart';import 'package:equatable/equatable.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter/foundation.dart';import '../field/field_controller.dart';import '../field/field_service.dart';@@ -39,7 +39,7 @@ class CellController<T, D> extends Equatable {String get viewId => cellId.viewId;- Int64 get rowId => cellId.rowId;+ RowId get rowId => cellId.rowId;String get fieldId => cellId.fieldInfo.id;diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dartindex e126fe4d6f..bb1eaaa414 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_listener.dart@@ -2,15 +2,16 @@ import 'package:appflowy/core/grid_notification.dart';import 'package:dartz/dartz.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/notification.pb.dart';-import 'package:fixnum/fixnum.dart';import 'package:flowy_infra/notifier.dart';import 'dart:async';import 'dart:typed_data';+import '../row/row_service.dart';+typedef UpdateFieldNotifiedValue = Either<Unit, FlowyError>;class CellListener {- final Int64 rowId;+ final RowId rowId;final String fieldId;PublishNotifier<UpdateFieldNotifiedValue>? _updateCellNotifier =PublishNotifier();diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dartindex 1b33b840bd..8b545246ad 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/cell/cell_service.dart@@ -9,12 +9,12 @@ import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/cell_entities.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter/foundation.dart';import 'package:freezed_annotation/freezed_annotation.dart';import 'dart:convert' show utf8;import '../field/field_controller.dart';+import '../row/row_service.dart';part 'cell_service.freezed.dart';part 'cell_data_loader.dart';part 'cell_cache.dart';@@ -52,7 +52,7 @@ class CellBackendService {class CellIdentifier with _$CellIdentifier {const factory CellIdentifier({required String viewId,- required Int64 rowId,+ required RowId rowId,required FieldInfo fieldInfo,}) = _CellIdentifier;diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dartindex 7405f85ed1..f7e8fdddbf 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_controller.dart@@ -13,12 +13,12 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';import 'package:collection/collection.dart';import 'dart:async';import 'package:dartz/dartz.dart';-import 'package:fixnum/fixnum.dart';import 'database_view_service.dart';import 'defines.dart';import 'layout/layout_setting_listener.dart';import 'row/row_cache.dart';import 'group/group_listener.dart';+import 'row/row_service.dart';typedef OnGroupByField = void Function(List<GroupPB>);typedef OnUpdateGroup = void Function(List<GroupPB>);@@ -157,7 +157,7 @@ class DatabaseController {}Future<Either<RowPB, FlowyError>> createRow({- Int64? startRowId,+ RowId? startRowId,String? groupId,void Function(RowDataBuilder builder)? withCells,}) {diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dartindex bb2d468fd0..548450966a 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart@@ -1,3 +1,4 @@+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/protobuf/flowy-database2/calendar_entities.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/database_entities.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/group_changeset.pb.dart';@@ -9,7 +10,6 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/group.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';-import 'package:fixnum/fixnum.dart';class DatabaseViewBackendService {final String viewId;@@ -25,12 +25,12 @@ class DatabaseViewBackendService {}Future<Either<RowPB, FlowyError>> createRow({- Int64? startRowId,+ RowId? startRowId,String? groupId,Map<String, String>? cellDataByFieldId,}) {var payload = CreateRowPayloadPB.create()..viewId = viewId;- payload.startRowId = startRowId ?? Int64(0);+ payload.startRowId = startRowId ?? "";if (groupId != null) {payload.groupId = groupId;@@ -44,9 +44,9 @@ class DatabaseViewBackendService {}Future<Either<Unit, FlowyError>> moveRow({- required Int64 fromRowId,+ required RowId fromRowId,required String toGroupId,- Int64? toRowId,+ RowId? toRowId,}) {var payload = MoveGroupRowPayloadPB.create()..viewId = viewIddiff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dartindex a91faf878d..526ae7a257 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/defines.dart@@ -2,22 +2,22 @@ import 'dart:collection';import 'package:appflowy_backend/protobuf/flowy-database2/database_entities.pb.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';-import 'package:fixnum/fixnum.dart';import '../grid/presentation/widgets/filter/filter_info.dart';import 'field/field_controller.dart';import 'row/row_cache.dart';+import 'row/row_service.dart';typedef OnFieldsChanged = void Function(UnmodifiableListView<FieldInfo>);typedef OnFiltersChanged = void Function(List<FilterInfo>);typedef OnDatabaseChanged = void Function(DatabasePB);-typedef OnRowsCreated = void Function(List<Int64> ids);-typedef OnRowsUpdated = void Function(List<Int64> ids);-typedef OnRowsDeleted = void Function(List<Int64> ids);+typedef OnRowsCreated = void Function(List<RowId> ids);+typedef OnRowsUpdated = void Function(List<RowId> ids);+typedef OnRowsDeleted = void Function(List<RowId> ids);typedef OnRowsChanged = void Function(UnmodifiableListView<RowInfo> rows,- UnmodifiableMapView<Int64, RowInfo> rowByRowId,+ UnmodifiableMapView<RowId, RowInfo> rowByRowId,RowsChangedReason reason,);diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dartindex 05fa3c913d..18aab93baf 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_cache.dart@@ -2,13 +2,13 @@ import 'dart:collection';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter/foundation.dart';import 'package:freezed_annotation/freezed_annotation.dart';import '../cell/cell_service.dart';import '../field/field_controller.dart';import 'row_list.dart';+import 'row_service.dart';part 'row_cache.freezed.dart';typedef RowUpdateCallback = void Function();@@ -43,7 +43,7 @@ class RowCache {return UnmodifiableListView(visibleRows);}- UnmodifiableMapView<Int64, RowInfo> get rowByRowId {+ UnmodifiableMapView<RowId, RowInfo> get rowByRowId {return UnmodifiableMapView(_rowList.rowInfoByRowId);}@@ -66,7 +66,7 @@ class RowCache {});}- RowInfo? getRow(Int64 rowId) {+ RowInfo? getRow(RowId rowId) {return _rowList.get(rowId);}@@ -116,7 +116,7 @@ class RowCache {}}- void _deleteRows(List<Int64> deletedRowIds) {+ void _deleteRows(List<RowId> deletedRowIds) {for (final rowId in deletedRowIds) {final deletedRow = _rowList.remove(rowId);if (deletedRow != null) {@@ -157,7 +157,7 @@ class RowCache {}}- void _hideRows(List<Int64> invisibleRows) {+ void _hideRows(List<RowId> invisibleRows) {for (final rowId in invisibleRows) {final deletedRow = _rowList.remove(rowId);if (deletedRow != null) {@@ -184,7 +184,7 @@ class RowCache {}RowUpdateCallback addListener({- required Int64 rowId,+ required RowId rowId,void Function(CellByFieldId, RowsChangedReason)? onCellUpdated,bool Function()? listenWhen,}) {@@ -220,7 +220,7 @@ class RowCache {_rowChangeReasonNotifier.removeListener(callback);}- CellByFieldId loadGridCells(Int64 rowId) {+ CellByFieldId loadGridCells(RowId rowId) {final RowPB? data = _rowList.get(rowId)?.rowPB;if (data == null) {_loadRow(rowId);@@ -228,7 +228,7 @@ class RowCache {return _makeGridCells(rowId, data);}- Future<void> _loadRow(Int64 rowId) async {+ Future<void> _loadRow(RowId rowId) async {final payload = RowIdPB.create()..viewId = viewId..rowId = rowId;@@ -240,7 +240,7 @@ class RowCache {);}- CellByFieldId _makeGridCells(Int64 rowId, RowPB? row) {+ CellByFieldId _makeGridCells(RowId rowId, RowPB? row) {// ignore: prefer_collection_literalsvar cellDataMap = CellByFieldId();for (final field in _delegate.fields) {@@ -320,7 +320,7 @@ typedef InsertedIndexs = List<InsertedIndex>;typedef DeletedIndexs = List<DeletedIndex>;// key: id of the row// value: UpdatedIndex-typedef UpdatedIndexMap = LinkedHashMap<Int64, UpdatedIndex>;+typedef UpdatedIndexMap = LinkedHashMap<RowId, UpdatedIndex>;@freezedclass RowsChangedReason with _$RowsChangedReason {@@ -338,7 +338,7 @@ class RowsChangedReason with _$RowsChangedReason {class InsertedIndex {final int index;- final Int64 rowId;+ final RowId rowId;InsertedIndex({required this.index,required this.rowId,@@ -356,7 +356,7 @@ class DeletedIndex {class UpdatedIndex {final int index;- final Int64 rowId;+ final RowId rowId;UpdatedIndex({required this.index,required this.rowId,diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dartindex 73b8056078..81509d61e3 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_data_controller.dart@@ -1,12 +1,12 @@-import 'package:fixnum/fixnum.dart';import 'package:flutter/material.dart';import '../cell/cell_service.dart';import 'row_cache.dart';+import 'row_service.dart';typedef OnRowChanged = void Function(CellByFieldId, RowsChangedReason);class RowController {- final Int64 rowId;+ final RowId rowId;final String viewId;final List<VoidCallback> _onRowChangedListeners = [];final RowCache _rowCache;diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dartindex 79d53ec714..b811e89c64 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_list.dart@@ -1,7 +1,7 @@import 'dart:collection';import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';-import 'package:fixnum/fixnum.dart';import 'row_cache.dart';+import 'row_service.dart';class RowList {/// Use List to reverse the order of the row.@@ -10,13 +10,13 @@ class RowList {List<RowInfo> get rows => List.from(_rowInfos);/// Use Map for faster access the raw row data.- final HashMap<Int64, RowInfo> rowInfoByRowId = HashMap();+ final HashMap<RowId, RowInfo> rowInfoByRowId = HashMap();- RowInfo? get(Int64 rowId) {+ RowInfo? get(RowId rowId) {return rowInfoByRowId[rowId];}- int? indexOfRow(Int64 rowId) {+ int? indexOfRow(RowId rowId) {final rowInfo = rowInfoByRowId[rowId];if (rowInfo != null) {return _rowInfos.indexOf(rowInfo);@@ -57,7 +57,7 @@ class RowList {}}- DeletedIndex? remove(Int64 rowId) {+ DeletedIndex? remove(RowId rowId) {final rowInfo = rowInfoByRowId[rowId];if (rowInfo != null) {final index = _rowInfos.indexOf(rowInfo);@@ -146,7 +146,7 @@ class RowList {}}- void moveRow(Int64 rowId, int oldIndex, int newIndex) {+ void moveRow(RowId rowId, int oldIndex, int newIndex) {final index = _rowInfos.indexWhere((rowInfo) => rowInfo.rowPB.id == rowId,);@@ -157,7 +157,7 @@ class RowList {}}- bool contains(Int64 rowId) {+ bool contains(RowId rowId) {return rowInfoByRowId[rowId] != null;}}diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_service.dartindex c4c0d66d21..cea02f1e01 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_service.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/row/row_service.dart@@ -2,7 +2,8 @@ import 'package:dartz/dartz.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';-import 'package:fixnum/fixnum.dart';++typedef RowId = String;class RowBackendService {final String viewId;@@ -11,7 +12,7 @@ class RowBackendService {required this.viewId,});- Future<Either<RowPB, FlowyError>> createRow(Int64 rowId) {+ Future<Either<RowPB, FlowyError>> createRow(RowId rowId) {final payload = CreateRowPayloadPB.create()..viewId = viewId..startRowId = rowId;@@ -19,7 +20,7 @@ class RowBackendService {return DatabaseEventCreateRow(payload).send();}- Future<Either<OptionalRowPB, FlowyError>> getRow(Int64 rowId) {+ Future<Either<OptionalRowPB, FlowyError>> getRow(RowId rowId) {final payload = RowIdPB.create()..viewId = viewId..rowId = rowId;@@ -27,7 +28,7 @@ class RowBackendService {return DatabaseEventGetRow(payload).send();}- Future<Either<Unit, FlowyError>> deleteRow(Int64 rowId) {+ Future<Either<Unit, FlowyError>> deleteRow(RowId rowId) {final payload = RowIdPB.create()..viewId = viewId..rowId = rowId;@@ -35,7 +36,7 @@ class RowBackendService {return DatabaseEventDeleteRow(payload).send();}- Future<Either<Unit, FlowyError>> duplicateRow(Int64 rowId) {+ Future<Either<Unit, FlowyError>> duplicateRow(RowId rowId) {final payload = RowIdPB.create()..viewId = viewId..rowId = rowId;diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart b/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dartindex 7f93054497..06fdcdf649 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/application/view/view_cache.dart@@ -1,7 +1,7 @@import 'dart:async';import 'dart:collection';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/log.dart';-import 'package:fixnum/fixnum.dart';import '../defines.dart';import '../field/field_controller.dart';import '../row/row_cache.dart';@@ -40,7 +40,7 @@ class DatabaseViewCache {UnmodifiableListView<RowInfo> get rowInfos => _rowCache.rowInfos;RowCache get rowCache => _rowCache;- RowInfo? getRow(Int64 rowId) => _rowCache.getRow(rowId);+ RowInfo? getRow(RowId rowId) => _rowCache.getRow(rowId);DatabaseViewCache({required this.viewId,diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dartindex e2dfd0d3d2..ea2b0e321b 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/board_bloc.dart@@ -1,6 +1,7 @@import 'dart:async';import 'dart:collection';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_board/appflowy_board.dart';import 'package:dartz/dartz.dart';import 'package:equatable/equatable.dart';@@ -8,7 +9,6 @@ import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:freezed_annotation/freezed_annotation.dart';@@ -311,7 +311,7 @@ class BoardEvent with _$BoardEvent {GroupPB group,RowPB row,) = _StartEditRow;- const factory BoardEvent.endEditingRow(Int64 rowId) = _EndEditRow;+ const factory BoardEvent.endEditingRow(RowId rowId) = _EndEditRow;const factory BoardEvent.didReceiveError(FlowyError error) = _DidReceiveError;const factory BoardEvent.didReceiveGridUpdate(DatabasePB grid,@@ -423,7 +423,7 @@ class GroupControllerDelegateImpl extends GroupControllerDelegate {}@override- void removeRow(GroupPB group, Int64 rowId) {+ void removeRow(GroupPB group, RowId rowId) {controller.removeGroupItem(group.groupId, rowId.toString());}diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dartindex ab010920c4..5987482ad7 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/board/application/group_controller.dart@@ -1,17 +1,17 @@+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';import 'dart:typed_data';import 'package:appflowy/core/grid_notification.dart';-import 'package:fixnum/fixnum.dart';import 'package:flowy_infra/notifier.dart';import 'package:dartz/dartz.dart';typedef OnGroupError = void Function(FlowyError);abstract class GroupControllerDelegate {- void removeRow(GroupPB group, Int64 rowId);+ void removeRow(GroupPB group, RowId rowId);void insertRow(GroupPB group, RowPB row, int? index);void updateRow(GroupPB group, RowPB row);void addNewRow(GroupPB group, RowPB row, int? index);diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dartindex d9209e3ca9..8f0be57af8 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/calendar/application/calendar_bloc.dart@@ -1,5 +1,6 @@import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/protobuf.dart';@@ -7,7 +8,6 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';import 'package:calendar_view/calendar_view.dart';import 'package:dartz/dartz.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:freezed_annotation/freezed_annotation.dart';@@ -83,7 +83,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {),);},- didDeleteEvents: (List<Int64> deletedRowIds) {+ didDeleteEvents: (List<RowId> deletedRowIds) {var events = [...state.allEvents];events.retainWhere((element) => !deletedRowIds.contains(element.event!.cellId.rowId),@@ -165,7 +165,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {return _databaseController.updateCalenderLayoutSetting(layoutSetting);}- Future<CalendarEventData<CalendarDayEvent>?> _loadEvent(Int64 rowId) async {+ Future<CalendarEventData<CalendarDayEvent>?> _loadEvent(RowId rowId) async {final payload = RowIdPB(viewId: viewId, rowId: rowId);return DatabaseEventGetCalendarEvent(payload).send().then((result) {return result.fold(@@ -324,7 +324,7 @@ class CalendarEvent with _$CalendarEvent {) = _DidReceiveNewEvent;// Called when deleting events- const factory CalendarEvent.didDeleteEvents(List<Int64> rowIds) =+ const factory CalendarEvent.didDeleteEvents(List<RowId> rowIds) =_DidDeleteEvents;// Called when creating a new event@@ -351,7 +351,7 @@ class CalendarState with _$CalendarState {required Events allEvents,required Events initialEvents,CalendarEventData<CalendarDayEvent>? newEvent,- required List<Int64> deleteEventIds,+ required List<RowId> deleteEventIds,CalendarEventData<CalendarDayEvent>? updateEvent,required Option<CalendarLayoutSettingPB> settings,required DatabaseLoadingState loadingState,@@ -391,6 +391,6 @@ class CalendarDayEvent {final CalendarEventPB event;final CellIdentifier cellId;- Int64 get eventId => cellId.rowId;+ RowId get eventId => cellId.rowId;CalendarDayEvent({required this.cellId, required this.event});}diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dartindex 26d8f96ae9..9946ef766c 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart@@ -6,7 +6,6 @@ import 'package:equatable/equatable.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:freezed_annotation/freezed_annotation.dart';import '../../application/field/field_controller.dart';@@ -66,7 +65,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {return super.close();}- RowCache? getRowCache(Int64 rowId) {+ RowCache? getRowCache(RowId rowId) {return databaseController.rowCache;}diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/card_cell.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/card_cell.dartindex 9e2ce6f164..a9e88a7277 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/card_cell.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/card/cells/card_cell.dart@@ -1,7 +1,7 @@import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';import 'package:appflowy_backend/protobuf/flowy-database2/select_option.pb.dart';-import 'package:fixnum/fixnum.dart';import 'package:flutter/material.dart';typedef CellRenderHook<C, T> = Widget? Function(C cellData, T cardData);@@ -122,7 +122,7 @@ abstract class EditableCell {class EditableCellId {String fieldId;- Int64 rowId;+ RowId rowId;EditableCellId(this.rowId, this.fieldId);diff --git a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dartindex 1b84409172..a2d0c8d06d 100644--- a/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart+++ b/frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/select_option_cell/select_option_service.dart@@ -1,11 +1,11 @@import 'package:appflowy/plugins/database_view/application/cell/cell_service.dart';import 'package:appflowy/plugins/database_view/application/field/type_option/type_option_service.dart';+import 'package:appflowy/plugins/database_view/application/row/row_service.dart';import 'package:appflowy_backend/protobuf/flowy-database2/select_option.pb.dart';import 'package:dartz/dartz.dart';import 'package:appflowy_backend/dispatch/dispatch.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-database2/cell_entities.pb.dart';-import 'package:fixnum/fixnum.dart';class SelectOptionBackendService {final CellIdentifier cellId;@@ -13,7 +13,7 @@ class SelectOptionBackendService {String get viewId => cellId.viewId;String get fieldId => cellId.fieldInfo.id;- Int64 get rowId => cellId.rowId;+ RowId get rowId => cellId.rowId;Future<Either<Unit, FlowyError>> create({required String name,diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lockindex f4085cce35..9ed2619c79 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock@@ -640,7 +640,6 @@ dependencies = [[[package]]name = "collab"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","bytes",@@ -658,7 +657,6 @@ dependencies = [[[package]]name = "collab-database"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","chrono",@@ -680,7 +678,6 @@ dependencies = [[[package]]name = "collab-derive"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["proc-macro2","quote",@@ -692,7 +689,6 @@ dependencies = [[[package]]name = "collab-document"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","collab",@@ -709,7 +705,6 @@ dependencies = [[[package]]name = "collab-folder"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","collab",@@ -727,7 +722,6 @@ dependencies = [[[package]]name = "collab-persistence"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["bincode","chrono",diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.tomlindex e9b69b7df7..e02d2f92f4 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml@@ -21,7 +21,7 @@ tauri-utils = "1.2"bytes = { version = "1.4" }tracing = { version = "0.1", features = ["log"] }lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = ["use_serde"] }-flowy-core = { path = "../../rust-lib/flowy-core", features = ["rev-sqlite","ts"] }+flowy-core = { path = "../../rust-lib/flowy-core", features = ["rev-sqlite", "ts"] }flowy-notification = { path = "../../rust-lib/flowy-notification", features = ["ts"] }[features]@@ -33,11 +33,11 @@ default = ["custom-protocol"]custom-protocol = ["tauri/custom-protocol"][patch.crates-io]-collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }+collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }#collab = { path = "../../AppFlowy-Collab/collab" }#collab-folder = { path = "../../AppFlowy-Collab/collab-folder" }diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/loadField.ts b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/loadField.tsindex 25471b07d7..94f5455c67 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/loadField.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/loadField.ts@@ -1,15 +1,7 @@import { TypeOptionController } from '../../../stores/effects/database/field/type_option/type_option_controller';import { Some } from 'ts-results';import { IDatabaseField, ISelectOption } from '../../../stores/reducers/database/slice';-import {- ChecklistTypeOptionPB,- DateFormat,- FieldType,- MultiSelectTypeOptionPB,- NumberFormat,- SingleSelectTypeOptionPB,- TimeFormat,-} from '@/services/backend';+import { ChecklistTypeOptionPB, FieldType, MultiSelectTypeOptionPB, SingleSelectTypeOptionPB } from '@/services/backend';import {makeChecklistTypeOptionContext,makeDateTypeOptionContext,@@ -78,7 +70,7 @@ export default async function (viewId: string, fieldInfo: FieldInfo, dispatch?:title: field.name,fieldType: field.field_type,fieldOptions: {- numberFormat: typeOption.format,+ NumberFormatPB: typeOption.format,},};}@@ -90,8 +82,8 @@ export default async function (viewId: string, fieldInfo: FieldInfo, dispatch?:title: field.name,fieldType: field.field_type,fieldOptions: {- dateFormat: typeOption.date_format,- timeFormat: typeOption.time_format,+ DateFormatPB: typeOption.date_format,+ TimeFormatPB: typeOption.time_format,includeTime: typeOption.include_time,},};diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.tsindex c065386533..22cbb3111a 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts@@ -91,7 +91,11 @@ export const useDatabase = (viewId: string, type?: ViewLayoutPB) => {if (source.droppableId === destination?.droppableId) {// move inside the block (group)- await controller.exchangeRow(group.rows[source.index].id, group.rows[destination.index].id);+ await controller.exchangeRow(+ group.rows[source.index].id,+ destination.droppableId,+ group.rows[destination.index].id+ );} else {// move to different block (group)if (!destination?.droppableId) return;diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridSingleSelectOptions.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridSingleSelectOptions.tsxindex e846e8de85..655f532cb1 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridSingleSelectOptions.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridSingleSelectOptions.tsx@@ -4,9 +4,9 @@ import { CellIdentifier } from '@/appflowy_app/stores/effects/database/cell/cellimport { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cache';import { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';import { useCell } from '$app/components/_shared/database-hooks/useCell';-import { SelectOptionCellDataPB, SelectOptionPB } from '@/services/backend/models/flowy-database/select_type_option';import { CellOptionsPopup } from '$app/components/_shared/EditRow/CellOptionsPopup';import { EditCellOptionPopup } from '$app/components/_shared/EditRow/EditCellOptionPopup';+import { SelectOptionCellDataPB, SelectOptionPB } from '@/services/backend';export default function GridSingleSelectOptions({cellIdentifier,diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridUrl.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridUrl.tsxindex 00bf66f11f..51bc760fd7 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridUrl.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/grid/GridCell/GridUrl.tsx@@ -3,7 +3,7 @@ import { CellCache } from '@/appflowy_app/stores/effects/database/cell/cell_cachimport { FieldController } from '@/appflowy_app/stores/effects/database/field/field_controller';import { useCell } from '../../_shared/database-hooks/useCell';import { EditCellUrl } from '../../_shared/EditRow/EditCellUrl';-import { URLCellDataPB } from '@/services/backend/models/flowy-database/url_type_option_entities';+import { URLCellDataPB } from '@/services/backend';export const GridUrl = ({cellIdentifier,diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGrid.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGrid.tsxindex 6fc8721e3e..8d0ebd04ce 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGrid.tsx+++ b/frontend/appflowy_tauri/src/appflowy_app/components/tests/TestGrid.tsx@@ -1,11 +1,11 @@import React from 'react';import {- DateFormat,+ DateFormatPB,FieldType,- NumberFormat,+ NumberFormatPB,NumberTypeOptionPB,SelectOptionCellDataPB,- TimeFormat,+ TimeFormatPB,ViewLayoutPB,} from '@/services/backend';import { Log } from '$app/utils/log';@@ -172,7 +172,7 @@ async function testEditDateCell() {await new Promise((resolve) => setTimeout(resolve, 200));}-async function testEditDateFormat() {+async function testEditDateFormatPB() {const view = await createTestDatabaseView(ViewLayoutPB.Grid);const databaseController = await openTestDatabase(view.id);await databaseController.open().then((result) => result.unwrap());@@ -184,20 +184,20 @@ async function testEditDateFormat() {// update date type optionconst dateTypeOptionContext = makeDateTypeOptionContext(typeOptionController);const typeOption = await dateTypeOptionContext.getTypeOption().then((a) => a.unwrap());- assert(typeOption.date_format === DateFormat.Friendly, 'Date format not match');- assert(typeOption.time_format === TimeFormat.TwentyFourHour, 'Time format not match');- typeOption.date_format = DateFormat.Local;- typeOption.time_format = TimeFormat.TwelveHour;+ assert(typeOption.date_format === DateFormatPB.Friendly, 'Date format not match');+ assert(typeOption.time_format === TimeFormatPB.TwentyFourHour, 'Time format not match');+ typeOption.date_format = DateFormatPB.Local;+ typeOption.time_format = TimeFormatPB.TwelveHour;await dateTypeOptionContext.setTypeOption(typeOption);const typeOption2 = await dateTypeOptionContext.getTypeOption().then((a) => a.unwrap());- assert(typeOption2.date_format === DateFormat.Local, 'Date format not match');- assert(typeOption2.time_format === TimeFormat.TwelveHour, 'Time format not match');+ assert(typeOption2.date_format === DateFormatPB.Local, 'Date format not match');+ assert(typeOption2.time_format === TimeFormatPB.TwelveHour, 'Time format not match');await new Promise((resolve) => setTimeout(resolve, 200));}-async function testEditNumberFormat() {+async function testEditNumberFormatPB() {const view = await createTestDatabaseView(ViewLayoutPB.Grid);const databaseController = await openTestDatabase(view.id);await databaseController.open().then((result) => result.unwrap());@@ -209,7 +209,7 @@ async function testEditNumberFormat() {// update date type optionconst dateTypeOptionContext = makeNumberTypeOptionContext(typeOptionController);const typeOption = await dateTypeOptionContext.getTypeOption().then((a) => a.unwrap());- typeOption.format = NumberFormat.EUR;+ typeOption.format = NumberFormatPB.EUR;typeOption.name = 'Money';await dateTypeOptionContext.setTypeOption(typeOption);@@ -366,8 +366,8 @@ async function testSwitchFromSingleSelectToNumber() {const numberTypeOption: NumberTypeOptionPB = await numberTypeOptionContext.getTypeOption().then((result) => result.unwrap());- const format: NumberFormat = numberTypeOption.format;- if (format !== NumberFormat.Num) {+ const format: NumberFormatPB = numberTypeOption.format;+ if (format !== NumberFormatPB.Num) {throw Error('The default format should be number');}@@ -491,10 +491,10 @@ export const TestEditDateCell = () => {return TestButton('Test editing date cell', testEditDateCell);};export const TestEditDateFormat = () => {- return TestButton('Test editing date format', testEditDateFormat);+ return TestButton('Test editing date format', testEditDateFormatPB);};export const TestEditNumberFormat = () => {- return TestButton('Test editing number format', testEditNumberFormat);+ return TestButton('Test editing number format', testEditNumberFormatPB);};export const TestEditCheckboxCell = () => {return TestButton('Test editing checkbox cell', testCheckboxCell);diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_bd_svc.tsindex 1b07ebfb0a..99d3a64f06 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/cell_bd_svc.ts@@ -1,4 +1,4 @@-import { DatabaseEventGetCell, DatabaseEventUpdateCell } from '@/services/backend/events/flowy-database';+import { DatabaseEventGetCell, DatabaseEventUpdateCell } from '@/services/backend/events/flowy-database2';import { CellChangesetPB, CellIdPB, FieldType } from '@/services/backend';class CellIdentifier {@@ -16,7 +16,7 @@ class CellBackendService {view_id: cellId.viewId,field_id: cellId.fieldId,row_id: cellId.rowId,- type_cell_data: data,+ cell_changeset: data,});return DatabaseEventUpdateCell(payload);};diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/data_persistence.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/data_persistence.tsindex affa40c7f5..19f7ea6ac8 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/data_persistence.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/data_persistence.ts@@ -2,7 +2,7 @@ import { Result } from 'ts-results';import { CellBackendService, CellIdentifier } from './cell_bd_svc';import { CalendarData } from './controller_builder';import { DateChangesetPB, FlowyError, CellIdPB } from '@/services/backend';-import { DatabaseEventUpdateDateCell } from '@/services/backend/events/flowy-database';+import { DatabaseEventUpdateDateCell } from '@/services/backend/events/flowy-database2';export abstract class CellDataPersistence<D> {abstract save(data: D): Promise<Result<void, FlowyError>>;diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/select_option_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/select_option_bd_svc.tsindex af4158db3b..f5a15669e3 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/select_option_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/cell/select_option_bd_svc.ts@@ -2,16 +2,17 @@ import { CellIdentifier } from './cell_bd_svc';import {CellIdPB,CreateSelectOptionPayloadPB,+ RepeatedSelectOptionPayload,SelectOptionCellChangesetPB,- SelectOptionChangesetPB,SelectOptionPB,} from '@/services/backend';import {DatabaseEventCreateSelectOption,+ DatabaseEventDeleteSelectOption,DatabaseEventGetSelectOptionCellData,- DatabaseEventUpdateSelectOption,+ DatabaseEventInsertOrUpdateSelectOption,DatabaseEventUpdateSelectOptionCell,-} from '@/services/backend/events/flowy-database';+} from '@/services/backend/events/flowy-database2';export class SelectOptionBackendService {constructor(public readonly viewId: string, public readonly fieldId: string) {}@@ -47,25 +48,33 @@ export class SelectOptionCellBackendService {};private _insertOption = (option: SelectOptionPB, isSelect: boolean) => {- const payload = SelectOptionChangesetPB.fromObject({ cell_identifier: this._cellIdentifier() });- if (isSelect) {- payload.insert_options.push(option);- } else {- payload.update_options.push(option);- }- return DatabaseEventUpdateSelectOption(payload);+ const payload = RepeatedSelectOptionPayload.fromObject({+ view_id: this.cellIdentifier.viewId,+ field_id: this.cellIdentifier.fieldId,+ row_id: this.cellIdentifier.rowId,+ });+ payload.items.push(option);+ return DatabaseEventInsertOrUpdateSelectOption(payload);};updateOption = (option: SelectOptionPB) => {- const payload = SelectOptionChangesetPB.fromObject({ cell_identifier: this._cellIdentifier() });- payload.update_options.push(option);- return DatabaseEventUpdateSelectOption(payload);+ const payload = RepeatedSelectOptionPayload.fromObject({+ view_id: this.cellIdentifier.viewId,+ field_id: this.cellIdentifier.fieldId,+ row_id: this.cellIdentifier.rowId,+ });+ payload.items.push(option);+ return DatabaseEventInsertOrUpdateSelectOption(payload);};deleteOption = (options: SelectOptionPB[]) => {- const payload = SelectOptionChangesetPB.fromObject({ cell_identifier: this._cellIdentifier() });- payload.delete_options.push(...options);- return DatabaseEventUpdateSelectOption(payload);+ const payload = RepeatedSelectOptionPayload.fromObject({+ view_id: this.cellIdentifier.viewId,+ field_id: this.cellIdentifier.fieldId,+ row_id: this.cellIdentifier.rowId,+ });+ payload.items.push(...options);+ return DatabaseEventDeleteSelectOption(payload);};getOptionCellData = () => {diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.tsindex 8b41f96f1c..4b17184ffc 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_bd_svc.ts@@ -14,7 +14,7 @@ import {MoveGroupPayloadPB,MoveGroupRowPayloadPB,MoveRowPayloadPB,-} from '@/services/backend/events/flowy-database';+} from '@/services/backend/events/flowy-database2';import {GetFieldPayloadPB,RepeatedFieldIdPB,@@ -65,13 +65,12 @@ export class DatabaseBackendService {};/// Move the row from one group to another group- /// [groupId] can be the moving row's group id or others./// [toRowId] is used to locate the moving row location.- moveGroupRow = (fromRowId: string, groupId: string, toRowId?: string) => {+ moveGroupRow = (fromRowId: string, toGroupId: string, toRowId?: string) => {const payload = MoveGroupRowPayloadPB.fromObject({view_id: this.viewId,from_row_id: fromRowId,- to_group_id: groupId,+ to_group_id: toGroupId,});if (toRowId !== undefined) {payload.to_row_id = toRowId;@@ -80,15 +79,6 @@ export class DatabaseBackendService {return DatabaseEventMoveGroupRow(payload);};- exchangeRow = (fromRowId: string, toRowId: string) => {- const payload = MoveRowPayloadPB.fromObject({- view_id: this.viewId,- from_row_id: fromRowId,- to_row_id: toRowId,- });- return DatabaseEventMoveRow(payload);- };-moveGroup = (fromGroupId: string, toGroupId: string) => {const payload = MoveGroupPayloadPB.fromObject({view_id: this.viewId,diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.tsindex 9c09eecacd..953acf1538 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/database_controller.ts@@ -75,11 +75,11 @@ export class DatabaseController {const settingsResult = await this.backendService.getSettings();if (settingsResult.ok) {const settings = settingsResult.val;- const groupConfig = settings.group_configurations.items;+ const groupConfig = settings.group_settings.items;if (groupConfig.length === 0) {return Err(new FlowyError({ msg: 'this database has no groups' }));}- return Ok(settings.group_configurations.items[0].field_id);+ return Ok(settings.group_settings.items[0].field_id);} else {return Err(settingsResult.val);}@@ -93,8 +93,8 @@ export class DatabaseController {return this.backendService.moveGroupRow(rowId, groupId);};- exchangeRow = async (fromRowId: string, toRowId: string) => {- await this.backendService.exchangeRow(fromRowId, toRowId);+ exchangeRow = async (fromRowId: string, toGroupId: string, toRowId?: string) => {+ await this.backendService.moveGroupRow(fromRowId, toGroupId, toRowId);await this.loadGroup();};diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/field_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/field_bd_svc.tsindex 2cec8c08cb..85ba2a599f 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/field_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/field_bd_svc.ts@@ -12,7 +12,7 @@ import {DatabaseEventGetTypeOption,DatabaseEventUpdateField,DatabaseEventUpdateFieldTypeOption,-} from '@/services/backend/events/flowy-database';+} from '@/services/backend/events/flowy-database2';export abstract class TypeOptionParser<T> {abstract fromBuffer(buffer: Uint8Array): T;diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_bd_svc.tsindex 6fb882a87a..31da01b9d8 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_bd_svc.ts@@ -1,14 +1,9 @@-import {- CreateFieldPayloadPB,- FieldType,- TypeOptionPathPB,- UpdateFieldTypePayloadPB,-} from '@/services/backend';+import { CreateFieldPayloadPB, FieldType, TypeOptionPathPB, UpdateFieldTypePayloadPB } from '@/services/backend';import {DatabaseEventCreateTypeOption,DatabaseEventGetTypeOption,DatabaseEventUpdateFieldType,-} from '@/services/backend/events/flowy-database';+} from '@/services/backend/events/flowy-database2';export class TypeOptionBackendService {constructor(public readonly viewId: string) {}diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_controller.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_controller.tsindex 7a56a083ed..86fd441cab 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_controller.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/field/type_option/type_option_controller.ts@@ -1,8 +1,8 @@import { FieldPB, FieldType, TypeOptionPB } from '@/services/backend';import { ChangeNotifier } from '$app/utils/change_notifier';-import { FieldBackendService, TypeOptionParser } from '../field_bd_svc';+import { FieldBackendService } from '../field_bd_svc';import { Log } from '$app/utils/log';-import { None, Ok, Option, Some } from 'ts-results';+import { None, Option, Some } from 'ts-results';import { FieldInfo } from '../field_controller';import { TypeOptionBackendService } from './type_option_bd_svc';diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_bd_svc.tsindex 180c313dc5..59770a34e2 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_bd_svc.ts@@ -4,7 +4,7 @@ import {DatabaseEventDeleteRow,DatabaseEventDuplicateRow,DatabaseEventGetRow,-} from '@/services/backend/events/flowy-database';+} from '@/services/backend/events/flowy-database2';export class RowBackendService {constructor(public readonly viewId: string) {}diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_cache.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_cache.tsindex 292175586d..38ce5aca28 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_cache.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_cache.ts@@ -12,7 +12,7 @@ import { ChangeNotifier } from '$app/utils/change_notifier';import { FieldInfo } from '../field/field_controller';import { CellCache, CellCacheKey } from '../cell/cell_cache';import { CellIdentifier } from '../cell/cell_bd_svc';-import { DatabaseEventGetRow } from '@/services/backend/events/flowy-database';+import { DatabaseEventGetRow } from '@/services/backend/events/flowy-database2';import { None, Option, Some } from 'ts-results';import { Log } from '$app/utils/log';diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/database/slice.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/database/slice.tsindex 1c4947e3cb..df2571a0d3 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/database/slice.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/database/slice.ts@@ -1,6 +1,6 @@import { createSlice, PayloadAction } from '@reduxjs/toolkit';-import { FieldType } from '@/services/backend/models/flowy-database/field_entities';-import { DateFormat, NumberFormat, SelectOptionColorPB, TimeFormat } from '@/services/backend';+import { FieldType } from '@/services/backend/models/flowy-database2/field_entities';+import { DateFormatPB, NumberFormatPB, SelectOptionColorPB, TimeFormatPB } from '@/services/backend';export interface ISelectOption {selectOptionId: string;@@ -13,13 +13,13 @@ export interface ISelectOptionType {}export interface IDateType {- dateFormat: DateFormat;- timeFormat: TimeFormat;+ DateFormatPB: DateFormatPB;+ TimeFormatPB: TimeFormatPB;includeTime: boolean;}export interface INumberType {- numberFormat: NumberFormat;+ NumberFormatPB: NumberFormatPB;}export interface IDatabaseField {diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/grid/slice.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/grid/slice.tsindex 5b72e7a270..2b3e72d768 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/grid/slice.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/reducers/grid/slice.ts@@ -1,6 +1,6 @@import { createSlice, PayloadAction } from '@reduxjs/toolkit';import { nanoid } from 'nanoid';-import { FieldType } from '@/services/backend/models/flowy-database/field_entities';+import { FieldType } from '@/services/backend/models/flowy-database2/field_entities';const initialState = {title: 'My plans on the week',diff --git a/frontend/appflowy_tauri/src/services/backend/index.ts b/frontend/appflowy_tauri/src/services/backend/index.tsindex 4c9332026c..ff33bdefca 100644--- a/frontend/appflowy_tauri/src/services/backend/index.ts+++ b/frontend/appflowy_tauri/src/services/backend/index.ts@@ -1,6 +1,6 @@export * from "./models/flowy-user";export * from "./models/flowy-document";-export * from "./models/flowy-database";+export * from "./models/flowy-database2";export * from "./models/flowy-folder2";export * from "./models/flowy-document2";export * from "./models/flowy-net";diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex fb0551c572..31abfded26 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -544,7 +544,6 @@ dependencies = [[[package]]name = "collab"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","bytes",@@ -562,7 +561,6 @@ dependencies = [[[package]]name = "collab-database"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","chrono",@@ -584,7 +582,6 @@ dependencies = [[[package]]name = "collab-derive"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["proc-macro2","quote",@@ -596,7 +593,6 @@ dependencies = [[[package]]name = "collab-document"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","collab",@@ -613,7 +609,6 @@ dependencies = [[[package]]name = "collab-folder"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["anyhow","collab",@@ -631,7 +626,6 @@ dependencies = [[[package]]name = "collab-persistence"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c5aba2#c5aba21c9652e76a0960ab1add329266d6e0e6e7"dependencies = ["bincode","chrono",diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.tomlindex 950116c8d8..948b121a5b 100644--- a/frontend/rust-lib/Cargo.toml+++ b/frontend/rust-lib/Cargo.toml@@ -40,11 +40,11 @@ opt-level = 3incremental = false[patch.crates-io]-collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }-collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c5aba2" }+collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }+collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "935868" }#collab = { path = "../AppFlowy-Collab/collab" }#collab-folder = { path = "../AppFlowy-Collab/collab-folder" }diff --git a/frontend/rust-lib/flowy-database2/src/entities/calendar_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/calendar_entities.rsindex d65699acb1..9d6077e351 100644--- a/frontend/rust-lib/flowy-database2/src/entities/calendar_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/calendar_entities.rs@@ -106,7 +106,7 @@ impl TryInto<CalendarEventRequestParams> for CalendarEventRequestPB {#[derive(Debug, Clone, Default, ProtoBuf)]pub struct CalendarEventPB {#[pb(index = 1)]- pub row_id: i64,+ pub row_id: String,#[pb(index = 2)]pub title_field_id: String,diff --git a/frontend/rust-lib/flowy-database2/src/entities/cell_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/cell_entities.rsindex 6314f87dc4..94ecc9866b 100644--- a/frontend/rust-lib/flowy-database2/src/entities/cell_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/cell_entities.rs@@ -49,7 +49,7 @@ pub struct CellIdPB {pub field_id: String,#[pb(index = 3)]- pub row_id: i64,+ pub row_id: String,}/// Represents as the cell identifier. It's used to locate the cell in corresponding@@ -81,7 +81,7 @@ pub struct CellPB {pub field_id: String,#[pb(index = 2)]- pub row_id: i64,+ pub row_id: String,/// Encoded the data using the helper struct `CellProtobufBlob`./// Check out the `CellProtobufBlob` for more information.@@ -94,7 +94,7 @@ pub struct CellPB {}impl CellPB {- pub fn new(field_id: &str, row_id: i64, field_type: FieldType, data: Vec<u8>) -> Self {+ pub fn new(field_id: &str, row_id: String, field_type: FieldType, data: Vec<u8>) -> Self {Self {field_id: field_id.to_owned(),row_id,@@ -103,7 +103,7 @@ impl CellPB {}}- pub fn empty(field_id: &str, row_id: i64) -> Self {+ pub fn empty(field_id: &str, row_id: String) -> Self {Self {field_id: field_id.to_owned(),row_id,@@ -144,7 +144,7 @@ pub struct CellChangesetPB {pub view_id: String,#[pb(index = 2)]- pub row_id: i64,+ pub row_id: String,#[pb(index = 3)]pub field_id: String,@@ -159,7 +159,7 @@ pub struct CellChangesetNotifyPB {pub view_id: String,#[pb(index = 2)]- pub row_id: i64,+ pub row_id: String,#[pb(index = 3)]pub field_id: String,diff --git a/frontend/rust-lib/flowy-database2/src/entities/database_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/database_entities.rsindex 7fe8f08088..f4a570fdcf 100644--- a/frontend/rust-lib/flowy-database2/src/entities/database_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/database_entities.rs@@ -83,10 +83,10 @@ pub struct MoveRowPayloadPB {pub view_id: String,#[pb(index = 2)]- pub from_row_id: i64,+ pub from_row_id: String,#[pb(index = 3)]- pub to_row_id: i64,+ pub to_row_id: String,}pub struct MoveRowParams {@@ -114,13 +114,13 @@ pub struct MoveGroupRowPayloadPB {pub view_id: String,#[pb(index = 2)]- pub from_row_id: i64,+ pub from_row_id: String,#[pb(index = 3)]pub to_group_id: String,#[pb(index = 4, one_of)]- pub to_row_id: Option<i64>,+ pub to_row_id: Option<String>,}pub struct MoveGroupRowParams {diff --git a/frontend/rust-lib/flowy-database2/src/entities/group_entities/group_changeset.rs b/frontend/rust-lib/flowy-database2/src/entities/group_entities/group_changeset.rsindex b5a2f19d21..59f2ba69ab 100644--- a/frontend/rust-lib/flowy-database2/src/entities/group_entities/group_changeset.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/group_entities/group_changeset.rs@@ -18,7 +18,7 @@ pub struct GroupRowsNotificationPB {pub inserted_rows: Vec<InsertedRowPB>,#[pb(index = 4)]- pub deleted_rows: Vec<i64>,+ pub deleted_rows: Vec<String>,#[pb(index = 5)]pub updated_rows: Vec<RowPB>,@@ -72,7 +72,7 @@ impl GroupRowsNotificationPB {}}- pub fn delete(group_id: String, deleted_rows: Vec<i64>) -> Self {+ pub fn delete(group_id: String, deleted_rows: Vec<String>) -> Self {Self {group_id,deleted_rows,diff --git a/frontend/rust-lib/flowy-database2/src/entities/row_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/row_entities.rsindex 235707d8e6..82ea8c8bec 100644--- a/frontend/rust-lib/flowy-database2/src/entities/row_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/row_entities.rs@@ -13,7 +13,7 @@ use crate::services::database::{InsertedRow, UpdatedRow};#[derive(Debug, Default, Clone, ProtoBuf, Eq, PartialEq)]pub struct RowPB {#[pb(index = 1)]- pub id: i64,+ pub id: String,#[pb(index = 2)]pub height: i32,@@ -22,7 +22,7 @@ pub struct RowPB {impl std::convert::From<&Row> for RowPB {fn from(row: &Row) -> Self {Self {- id: row.id.into(),+ id: row.id.clone().into_inner(),height: row.height,}}@@ -31,7 +31,7 @@ impl std::convert::From<&Row> for RowPB {impl std::convert::From<Row> for RowPB {fn from(row: Row) -> Self {Self {- id: row.id.into(),+ id: row.id.into_inner(),height: row.height,}}@@ -39,7 +39,7 @@ impl std::convert::From<Row> for RowPB {impl From<RowOrder> for RowPB {fn from(data: RowOrder) -> Self {Self {- id: data.id.into(),+ id: data.id.into_inner(),height: data.height,}}@@ -144,7 +144,7 @@ pub struct RowIdPB {pub view_id: String,#[pb(index = 2)]- pub row_id: i64,+ pub row_id: String,}pub struct RowIdParams {@@ -180,7 +180,7 @@ pub struct CreateRowPayloadPB {pub view_id: String,#[pb(index = 2, one_of)]- pub start_row_id: Option<i64>,+ pub start_row_id: Option<String>,#[pb(index = 3, one_of)]pub group_id: Option<String>,diff --git a/frontend/rust-lib/flowy-database2/src/entities/sort_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/sort_entities.rsindex 76b0c53a62..e4479a6874 100644--- a/frontend/rust-lib/flowy-database2/src/entities/sort_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/sort_entities.rs@@ -247,7 +247,7 @@ pub struct ReorderAllRowsPB {#[derive(Debug, Default, ProtoBuf)]pub struct ReorderSingleRowPB {#[pb(index = 1)]- pub row_id: i64,+ pub row_id: String,#[pb(index = 2)]pub old_index: i32,diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option.rsindex 286eb64375..7468cc2d6f 100644--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option.rs@@ -49,7 +49,7 @@ pub struct RepeatedSelectOptionPayload {pub field_id: String,#[pb(index = 3)]- pub row_id: i64,+ pub row_id: String,#[pb(index = 4)]pub items: Vec<SelectOptionPB>,diff --git a/frontend/rust-lib/flowy-database2/src/entities/view_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/view_entities.rsindex 70368b7785..8baeca7799 100644--- a/frontend/rust-lib/flowy-database2/src/entities/view_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/entities/view_entities.rs@@ -11,7 +11,7 @@ pub struct RowsVisibilityChangesetPB {pub visible_rows: Vec<InsertedRowPB>,#[pb(index = 6)]- pub invisible_rows: Vec<i64>,+ pub invisible_rows: Vec<String>,}#[derive(Debug, Default, Clone, ProtoBuf)]@@ -23,7 +23,7 @@ pub struct RowsChangesetPB {pub inserted_rows: Vec<InsertedRowPB>,#[pb(index = 3)]- pub deleted_rows: Vec<i64>,+ pub deleted_rows: Vec<String>,#[pb(index = 4)]pub updated_rows: Vec<UpdatedRowPB>,@@ -38,7 +38,7 @@ impl RowsChangesetPB {}}- pub fn from_delete(view_id: String, deleted_rows: Vec<i64>) -> Self {+ pub fn from_delete(view_id: String, deleted_rows: Vec<String>) -> Self {Self {view_id,deleted_rows,@@ -56,7 +56,7 @@ impl RowsChangesetPB {pub fn from_move(view_id: String,- deleted_rows: Vec<i64>,+ deleted_rows: Vec<String>,inserted_rows: Vec<InsertedRowPB>,) -> Self {Self {diff --git a/frontend/rust-lib/flowy-database2/src/event_handler.rs b/frontend/rust-lib/flowy-database2/src/event_handler.rsindex e9a70f404a..96230faf2d 100644--- a/frontend/rust-lib/flowy-database2/src/event_handler.rs+++ b/frontend/rust-lib/flowy-database2/src/event_handler.rs@@ -280,7 +280,7 @@ pub(crate) async fn get_row_handler() -> DataResult<OptionalRowPB, FlowyError> {let params: RowIdParams = data.into_inner().try_into()?;let database_editor = manager.get_database(¶ms.view_id).await?;- let row = database_editor.get_row(params.row_id).map(RowPB::from);+ let row = database_editor.get_row(¶ms.row_id).map(RowPB::from);data_result_ok(OptionalRowPB { row })}@@ -291,7 +291,7 @@ pub(crate) async fn delete_row_handler() -> Result<(), FlowyError> {let params: RowIdParams = data.into_inner().try_into()?;let database_editor = manager.get_database(¶ms.view_id).await?;- database_editor.delete_row(params.row_id).await;+ database_editor.delete_row(¶ms.row_id).await;Ok(())}@@ -303,7 +303,7 @@ pub(crate) async fn duplicate_row_handler(let params: RowIdParams = data.into_inner().try_into()?;let database_editor = manager.get_database(¶ms.view_id).await?;database_editor- .duplicate_row(¶ms.view_id, params.row_id)+ .duplicate_row(¶ms.view_id, ¶ms.row_id).await;Ok(())}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.rsindex 64023da091..86b7c03063 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@@ -285,7 +285,7 @@ impl DatabaseEditor {Ok(())}- pub async fn duplicate_row(&self, view_id: &str, row_id: RowId) {+ pub async fn duplicate_row(&self, view_id: &str, row_id: &RowId) {let _ = self.database.lock().duplicate_row(view_id, row_id);}@@ -325,7 +325,7 @@ impl DatabaseEditor {is_new: true,}));- let row = self.database.lock().get_row(row_order.id);+ let row = self.database.lock().get_row(&row_order.id);if let Some(row) = row {for view in self.database_views.editors().await {view.v_did_create_row(&row, ¶ms.group_id, index).await;@@ -413,17 +413,17 @@ impl DatabaseEditor {Ok(view_editor.v_get_rows().await)}- pub fn get_row(&self, row_id: RowId) -> Option<Row> {+ pub fn get_row(&self, row_id: &RowId) -> Option<Row> {self.database.lock().get_row(row_id)}- pub async fn delete_row(&self, row_id: RowId) {+ pub async fn delete_row(&self, row_id: &RowId) {let row = self.database.lock().remove_row(row_id);if let Some(row) = row {tracing::trace!("Did delete row:{:?}", row);let _ = self.row_event_tx- .send(DatabaseRowEvent::DeleteRow(row.id.into()));+ .send(DatabaseRowEvent::DeleteRow(row.id.clone()));for view in self.database_views.editors().await {view.v_did_delete_row(&row).await;@@ -433,7 +433,7 @@ impl DatabaseEditor {pub async fn get_cell(&self, field_id: &str, row_id: RowId) -> CellPB {let field = self.database.lock().fields.get_field(field_id);- let cell = self.database.lock().get_cell(field_id, row_id);+ let cell = self.database.lock().get_cell(field_id, &row_id);match (field, cell) {(Some(field), Some(cell)) => {let field_type = FieldType::from(field.field_type);@@ -445,7 +445,7 @@ impl DatabaseEditor {field_type: Some(field_type),}},- _ => CellPB::empty(field_id, row_id.into()),+ _ => CellPB::empty(field_id, row_id.into_inner()),}}@@ -467,7 +467,7 @@ impl DatabaseEditor {let database = self.database.lock();(database.fields.get_field(field_id)?,- database.get_cell(field_id, row_id).map(|cell| cell.cell),+ database.get_cell(field_id, &row_id).map(|cell| cell.cell),)};let cell_changeset = cell_changeset.to_cell_changeset_str();@@ -485,15 +485,15 @@ impl DatabaseEditor {) -> Option<()> {let old_row = {let database = self.database.lock();- database.get_row(row_id)+ database.get_row(&row_id)};- self.database.lock().update_row(row_id, |row_update| {+ self.database.lock().update_row(&row_id, |row_update| {row_update.update_cells(|cell_update| {cell_update.insert(field_id, new_cell);});});- let option_row = self.database.lock().get_row(row_id);+ let option_row = self.database.lock().get_row(&row_id);if let Some(new_row) = option_row {let _ = self.row_event_tx@@ -508,7 +508,7 @@ impl DatabaseEditor {notify_did_update_cell(vec![CellChangesetNotifyPB {view_id: view_id.to_string(),- row_id: row_id.into(),+ row_id: row_id.into_inner(),field_id: field_id.to_string(),}]).await;@@ -593,7 +593,7 @@ impl DatabaseEditor {match field {None => SelectOptionCellDataPB::default(),Some(field) => {- let row_cell = self.database.lock().get_cell(field_id, row_id);+ let row_cell = self.database.lock().get_cell(field_id, &row_id);let ids = match row_cell {None => SelectOptionIds::new(),Some(row_cell) => SelectOptionIds::from(&row_cell.cell),@@ -640,7 +640,7 @@ impl DatabaseEditor {from_row: RowId,to_row: Option<RowId>,) -> FlowyResult<()> {- let row = self.database.lock().get_row(from_row);+ let row = self.database.lock().get_row(&from_row);match row {None => {tracing::warn!(@@ -649,14 +649,14 @@ impl DatabaseEditor {)},Some(row) => {- let mut row_changeset = RowChangeset::new(row.id);+ let mut row_changeset = RowChangeset::new(row.id.clone());let view = self.database_views.get_view_editor(view_id).await?;view.v_move_group_row(&row, &mut row_changeset, to_group, to_row).await;tracing::trace!("Row data changed: {:?}", row_changeset);- self.database.lock().update_row(row.id, |row| {+ self.database.lock().update_row(&row.id, |row| {row.set_cells(Cells::from(row_changeset.cell_by_field_id.clone()));});@@ -811,12 +811,12 @@ fn cell_changesets_from_cell_by_field_id(row_id: RowId,cell_by_field_id: HashMap<String, Cell>,) -> Vec<CellChangesetNotifyPB> {- let row_id = row_id.into();+ let row_id = row_id.into_inner();cell_by_field_id.into_iter().map(|(field_id, _cell)| CellChangesetNotifyPB {view_id: view_id.to_string(),- row_id,+ row_id: row_id.clone(),field_id,}).collect()@@ -879,14 +879,14 @@ impl DatabaseViewData for DatabaseViewDataImpl {to_fut(async move { field })}- fn index_of_row(&self, view_id: &str, row_id: RowId) -> Fut<Option<usize>> {+ fn index_of_row(&self, view_id: &str, row_id: &RowId) -> Fut<Option<usize>> {let index = self.database.lock().index_of_row(view_id, row_id);to_fut(async move { index })}- fn get_row(&self, view_id: &str, row_id: RowId) -> Fut<Option<(usize, Arc<Row>)>> {+ fn get_row(&self, view_id: &str, row_id: &RowId) -> Fut<Option<(usize, Arc<Row>)>> {let index = self.database.lock().index_of_row(view_id, row_id);- let row = self.database.lock().get_row(row_id);+ let row = self.database.lock().get_row(&row_id);to_fut(async move {match (index, row) {(Some(index), Some(row)) => Some((index, Arc::new(row))),@@ -905,7 +905,7 @@ impl DatabaseViewData for DatabaseViewDataImpl {to_fut(async move { cells.into_iter().map(Arc::new).collect() })}- fn get_cell_in_row(&self, field_id: &str, row_id: RowId) -> Fut<Option<Arc<RowCell>>> {+ fn get_cell_in_row(&self, field_id: &str, row_id: &RowId) -> Fut<Option<Arc<RowCell>>> {let cell = self.database.lock().get_cell(field_id, row_id);to_fut(async move { cell.map(Arc::new) })}diff --git a/frontend/rust-lib/flowy-database2/src/services/database/entities.rs b/frontend/rust-lib/flowy-database2/src/services/database/entities.rsindex acaeb4b2e1..66693b02e2 100644--- a/frontend/rust-lib/flowy-database2/src/services/database/entities.rs+++ b/frontend/rust-lib/flowy-database2/src/services/database/entities.rs@@ -1,12 +1,13 @@+use collab_database::rows::RowId;use collab_database::views::RowOrder;#[derive(Debug, Clone)]pub enum DatabaseRowEvent {InsertRow(InsertedRow),UpdateRow(UpdatedRow),- DeleteRow(i64),+ DeleteRow(RowId),Move {- deleted_row_id: i64,+ deleted_row_id: RowId,inserted_row: InsertedRow,},}diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/notifier.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/notifier.rsindex 48e05a017c..fe832e890c 100644--- a/frontend/rust-lib/flowy-database2/src/services/database_view/notifier.rs+++ b/frontend/rust-lib/flowy-database2/src/services/database_view/notifier.rs@@ -41,7 +41,11 @@ impl DatabaseViewChangedReceiverRunner {let changeset = RowsVisibilityChangesetPB {view_id: notification.view_id,visible_rows: notification.visible_rows,- invisible_rows: notification.invisible_rows,+ invisible_rows: notification+ .invisible_rows+ .into_iter()+ .map(|row| row.into_inner())+ .collect(),};send_notification(@@ -61,7 +65,7 @@ impl DatabaseViewChangedReceiverRunner {},DatabaseViewChanged::ReorderSingleRowNotification(notification) => {let reorder_row = ReorderSingleRowPB {- row_id: notification.row_id,+ row_id: notification.row_id.into_inner(),old_index: notification.old_index as i32,new_index: notification.new_index as i32,};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.rsindex 615d8fbc29..51ef077936 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@@ -50,16 +50,16 @@ pub trait DatabaseViewData: Send + Sync + 'static {fn get_primary_field(&self) -> Fut<Option<Arc<Field>>>;/// Returns the index of the row with row_id- fn index_of_row(&self, view_id: &str, row_id: RowId) -> Fut<Option<usize>>;+ fn index_of_row(&self, view_id: &str, row_id: &RowId) -> Fut<Option<usize>>;/// Returns the `index` and `RowRevision` with row_id- fn get_row(&self, view_id: &str, row_id: RowId) -> Fut<Option<(usize, Arc<Row>)>>;+ fn get_row(&self, view_id: &str, row_id: &RowId) -> Fut<Option<(usize, Arc<Row>)>>;fn get_rows(&self, view_id: &str) -> Fut<Vec<Arc<Row>>>;fn get_cells_for_field(&self, view_id: &str, field_id: &str) -> Fut<Vec<Arc<RowCell>>>;- fn get_cell_in_row(&self, field_id: &str, row_id: RowId) -> Fut<Option<Arc<RowCell>>>;+ fn get_cell_in_row(&self, field_id: &str, row_id: &RowId) -> Fut<Option<Arc<RowCell>>>;fn get_layout_for_view(&self, view_id: &str) -> DatabaseLayout;@@ -248,9 +248,11 @@ impl DatabaseViewEditor {let filter_controller = self.filter_controller.clone();let sort_controller = self.sort_controller.clone();- let row_id = row.id;+ let row_id = row.id.clone();tokio::spawn(async move {- filter_controller.did_receive_row_changed(row_id).await;+ filter_controller+ .did_receive_row_changed(row_id.clone())+ .await;sort_controller.read().await@@ -669,12 +671,12 @@ impl DatabaseViewEditor {// Textlet primary_field = self.delegate.get_primary_field().await?;- let text_cell = get_cell_for_row(self.delegate.clone(), &primary_field.id, row_id).await?;+ let text_cell = get_cell_for_row(self.delegate.clone(), &primary_field.id, &row_id).await?;// Datelet date_field = self.delegate.get_field(&calendar_setting.field_id).await?;- let date_cell = get_cell_for_row(self.delegate.clone(), &date_field.id, row_id).await?;+ let date_cell = get_cell_for_row(self.delegate.clone(), &date_field.id, &row_id).await?;let title = text_cell.into_text_field_cell_data().unwrap_or_default()@@ -687,7 +689,7 @@ impl DatabaseViewEditor {.unwrap_or_default();Some(CalendarEventPB {- row_id: row_id.into(),+ row_id: row_id.into_inner(),title_field_id: primary_field.id.clone(),title,timestamp,@@ -712,7 +714,7 @@ impl DatabaseViewEditor {.await.into_iter().map(|date_cell| {- let row_id = date_cell.row_id;+ let row_id = date_cell.row_id.clone();// timestamplet timestamp = date_cell@@ -727,7 +729,7 @@ impl DatabaseViewEditor {let mut events: Vec<CalendarEventPB> = vec![];for text_cell in text_cells {let title_field_id = text_cell.field_id.clone();- let row_id = text_cell.row_id;+ let row_id = text_cell.row_id.clone();let timestamp = timestamp_by_row_id.get(&row_id).cloned()@@ -739,7 +741,7 @@ impl DatabaseViewEditor {.into();let event = CalendarEventPB {- row_id: row_id.into(),+ row_id: row_id.into_inner(),title_field_id,title,timestamp,@@ -758,14 +760,14 @@ impl DatabaseViewEditor {RowsChangesetPB::from_update(self.view_id.clone(), vec![row.into()])},DatabaseRowEvent::DeleteRow(row_id) => {- RowsChangesetPB::from_delete(self.view_id.clone(), vec![row_id])+ RowsChangesetPB::from_delete(self.view_id.clone(), vec![row_id.into_inner()])},DatabaseRowEvent::Move {deleted_row_id,inserted_row,} => RowsChangesetPB::from_move(self.view_id.clone(),- vec![deleted_row_id],+ vec![deleted_row_id.into_inner()],vec![inserted_row.into()],),};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.rsindex 9d64a725b8..581fceef32 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@@ -60,7 +60,7 @@ impl FilterDelegate for DatabaseViewFilterDelegateImpl {self.0.get_rows(view_id)}- fn get_row(&self, view_id: &str, row_id: RowId) -> Fut<Option<(usize, Arc<Row>)>> {- self.0.get_row(view_id, row_id)+ fn get_row(&self, view_id: &str, rows_id: &RowId) -> Fut<Option<(usize, Arc<Row>)>> {+ self.0.get_row(view_id, rows_id)}}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.rsindex 6feb005d2c..073bbd84ad 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@@ -90,16 +90,16 @@ impl GroupSettingReader for GroupSettingReaderImpl {pub(crate) async fn get_cell_for_row(delegate: Arc<dyn DatabaseViewData>,field_id: &str,- row_id: RowId,+ row_id: &RowId,) -> Option<RowSingleCellData> {let field = delegate.get_field(field_id).await?;- let cell = delegate.get_cell_in_row(field_id, row_id).await?;+ let cell = delegate.get_cell_in_row(field_id, &row_id).await?;let field_type = FieldType::from(field.field_type);if let Some(handler) = delegate.get_type_option_cell_handler(&field, &field_type) {return match handler.get_cell_data(&cell, &field_type, &field) {Ok(cell_data) => Some(RowSingleCellData {- row_id: cell.row_id,+ row_id: cell.row_id.clone(),field_id: field.id.clone(),field_type: field_type.clone(),cell_data,@@ -125,7 +125,7 @@ pub(crate) async fn get_cells_for_field(.flat_map(|cell| match handler.get_cell_data(cell, &field_type, &field) {Ok(cell_data) => Some(RowSingleCellData {- row_id: cell.row_id,+ row_id: cell.row_id.clone(),field_id: field.id.clone(),field_type: field_type.clone(),cell_data,diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/views.rsindex 6979a2bc63..daeea1ab57 100644--- a/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs+++ b/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs@@ -67,7 +67,7 @@ impl DatabaseViews {recv_row_changeset: impl FnOnce(RowChangeset) -> Fut<()>,) -> FlowyResult<()> {let view_editor = self.get_view_editor(view_id).await?;- let mut row_changeset = RowChangeset::new(row.id);+ let mut row_changeset = RowChangeset::new(row.id.clone());view_editor.v_move_group_row(&row, &mut row_changeset, &to_group_id, to_row_id).await;diff --git a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rsindex a6ab492b04..6deb42fc4d 100644--- a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs+++ b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs@@ -24,7 +24,7 @@ pub trait FilterDelegate: Send + Sync + 'static {fn get_field(&self, field_id: &str) -> Fut<Option<Arc<Field>>>;fn get_fields(&self, view_id: &str, field_ids: Option<Vec<String>>) -> Fut<Vec<Arc<Field>>>;fn get_rows(&self, view_id: &str) -> Fut<Vec<Arc<Row>>>;- fn get_row(&self, view_id: &str, rows_id: RowId) -> Fut<Option<(usize, Arc<Row>)>>;+ fn get_row(&self, view_id: &str, rows_id: &RowId) -> Fut<Option<(usize, Arc<Row>)>>;}pub trait FromFilterString {@@ -149,7 +149,7 @@ impl FilterController {}async fn filter_row(&self, row_id: RowId) -> FlowyResult<()> {- if let Some((_, row)) = self.delegate.get_row(&self.view_id, row_id).await {+ if let Some((_, row)) = self.delegate.get_row(&self.view_id, &row_id).await {let field_by_field_id = self.get_field_map().await;let mut notification = FilterResultNotification::new(self.view_id.clone());if let Some((row_id, is_visible)) = filter_row(@@ -160,14 +160,14 @@ impl FilterController {&self.cell_filter_cache,) {if is_visible {- if let Some((index, row)) = self.delegate.get_row(&self.view_id, row_id).await {+ if let Some((index, row)) = self.delegate.get_row(&self.view_id, &row_id).await {let row_pb = RowPB::from(row.as_ref());notification.visible_rows.push(InsertedRowPB::with_index(row_pb, index as i32))}} else {- notification.invisible_rows.push(row_id.into());+ notification.invisible_rows.push(row_id);}}@@ -201,7 +201,7 @@ impl FilterController {let row_pb = RowPB::from(row.as_ref());visible_rows.push(InsertedRowPB::with_index(row_pb, index as i32))} else {- invisible_rows.push(i64::from(row_id));+ invisible_rows.push(row_id);}}}@@ -369,7 +369,7 @@ fn filter_row() -> Option<(RowId, bool)> {// Create a filter result cache if it's not existlet mut filter_result = result_by_row_id- .entry(row.id)+ .entry(row.id.clone()).or_insert_with(FilterResult::default);let old_is_visible = filter_result.is_visible();@@ -395,7 +395,7 @@ fn filter_row(let is_visible = filter_result.is_visible();if old_is_visible != is_visible {- Some((row.id, is_visible))+ Some((row.id.clone(), is_visible))} else {None}diff --git a/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs b/frontend/rust-lib/flowy-database2/src/services/filter/entities.rsindex befb378d0e..c229952535 100644--- a/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs+++ b/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs@@ -1,5 +1,6 @@use anyhow::bail;use collab::core::any_map::AnyMapExtension;+use collab_database::rows::RowId;use collab_database::views::{FilterMap, FilterMapBuilder};use crate::entities::{DeleteFilterParams, FieldType, FilterPB, InsertedRowPB};@@ -161,7 +162,7 @@ pub struct FilterResultNotification {pub visible_rows: Vec<InsertedRowPB>,// Indicates there will be some new rows being invisible from visible state.- pub invisible_rows: Vec<i64>,+ pub invisible_rows: Vec<RowId>,}impl FilterResultNotification {diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller.rsindex edf1e5863d..bf7d5949fe 100644--- a/frontend/rust-lib/flowy-database2/src/services/group/controller.rs+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller.rs@@ -63,7 +63,7 @@ pub struct MoveGroupRowContext<'a> {pub to_row_id: Option<RowId>,}-#[derive(Debug, Clone, Default)]+#[derive(Debug, Clone)]pub struct RowChangeset {pub row_id: RowId,pub height: Option<i32>,@@ -77,7 +77,9 @@ impl RowChangeset {pub fn new(row_id: RowId) -> Self {Self {row_id,- ..Default::default()+ height: None,+ visibility: None,+ cell_by_field_id: Default::default(),}}@@ -149,7 +151,7 @@ where.iter().any(|inserted_row| &inserted_row.row.id == row_id)})- .collect::<Vec<i64>>();+ .collect::<Vec<String>>();let mut changeset = GroupRowsNotificationPB::new(no_status_group.id.clone());if !no_status_group_rows.is_empty() {@@ -158,7 +160,7 @@ where}// [other_group_delete_rows] contains all the deleted rows except the default group.- let other_group_delete_rows: Vec<i64> = other_group_changesets+ let other_group_delete_rows: Vec<String> = other_group_changesets.iter().flat_map(|changeset| &changeset.deleted_rows).cloned()@@ -172,29 +174,24 @@ where// out from the default_group.!other_group_delete_rows.iter()- .any(|row_id| inserted_row.row.id == *row_id)+ .any(|row_id| &inserted_row.row.id == row_id)}).collect::<Vec<&InsertedRowPB>>();let mut deleted_row_ids = vec![];for row in &no_status_group.rows {- let row_id: i64 = row.id.into();+ let row_id = row.id.clone().into_inner();if default_group_deleted_rows.iter().any(|deleted_row| deleted_row.row.id == row_id){- deleted_row_ids.push(row.id);+ deleted_row_ids.push(row_id);}}no_status_group.rows.retain(|row| !deleted_row_ids.contains(&row.id));- changeset.deleted_rows.extend(- deleted_row_ids- .into_iter()- .map(|id| id.into())- .collect::<Vec<i64>>(),- );+ changeset.deleted_rows.extend(deleted_row_ids);Some(changeset)}}@@ -328,12 +325,12 @@ wheretracing::error!("Unexpected None value. It should have the no status group");},Some(no_status_group) => {- if !no_status_group.contains_row(row.id) {+ if !no_status_group.contains_row(&row.id) {tracing::error!("The row: {:?} should be in the no status group", row.id);}result.row_changesets = vec![GroupRowsNotificationPB::delete(no_status_group.id.clone(),- vec![row.id.into()],+ vec![row.id.clone().into_inner()],)];},}diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rsindex eb834801c9..f9f32e18ca 100644--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs@@ -54,12 +54,12 @@ impl GroupCustomize for CheckboxGroupController {let mut changesets = vec![];self.group_ctx.iter_mut_status_groups(|group| {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());- let is_not_contained = !group.contains_row(row.id);+ let is_not_contained = !group.contains_row(&row.id);if group.id == CHECK {if cell_data.is_uncheck() {// Remove the row if the group.id is CHECK but the cell_data is UNCHECK- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());+ group.remove_row(&row.id);} else {// Add the row to the group if the group didn't contain the rowif is_not_contained {@@ -74,8 +74,8 @@ impl GroupCustomize for CheckboxGroupController {if group.id == UNCHECK {if cell_data.is_check() {// Remove the row if the group.id is UNCHECK but the cell_data is CHECK- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());+ group.remove_row(&row.id);} else {// Add the row to the group if the group didn't contain the rowif is_not_contained {@@ -98,9 +98,9 @@ impl GroupCustomize for CheckboxGroupController {let mut changesets = vec![];self.group_ctx.iter_mut_groups(|group| {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());- if group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ if group.contains_row(&row.id) {+ changeset.deleted_rows.push(row.id.clone().into_inner());+ group.remove_row(&row.id);}if !changeset.is_empty() {diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rsindex 07a664711d..c8a1e53148 100644--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs@@ -16,22 +16,22 @@ pub fn add_or_remove_select_option_row() -> Option<GroupRowsNotificationPB> {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());if cell_data.select_options.is_empty() {- if group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ if group.contains_row(&row.id) {+ group.remove_row(&row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());}} else {cell_data.select_options.iter().for_each(|option| {if option.id == group.id {- if !group.contains_row(row.id) {+ if !group.contains_row(&row.id) {changeset.inserted_rows.push(InsertedRowPB::new(RowPB::from(row)));group.add_row(row.clone());}- } else if group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ } else if group.contains_row(&row.id) {+ group.remove_row(&row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());}});}@@ -50,9 +50,9 @@ pub fn remove_select_option_row() -> Option<GroupRowsNotificationPB> {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());cell_data.select_options.iter().for_each(|option| {- if option.id == group.id && group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ if option.id == group.id && group.contains_row(&row.id) {+ group.remove_row(&row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());}});@@ -76,17 +76,17 @@ pub fn move_group_row(to_row_id,} = context;- let from_index = group.index_of_row(row.id);+ let from_index = group.index_of_row(&row.id);let to_index = match to_row_id {None => None,- Some(to_row_id) => group.index_of_row(*to_row_id),+ Some(to_row_id) => group.index_of_row(to_row_id),};// Remove the row in which group contains itif let Some(from_index) = &from_index {- changeset.deleted_rows.push(row.id.into());+ changeset.deleted_rows.push(row.id.clone().into_inner());tracing::debug!("Group:{} remove {} at {}", group.id, row.id, from_index);- group.remove_row(row.id);+ group.remove_row(&row.id);}if group.id == *to_group_id {diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rsindex 90f72a2429..7580b9d5da 100644--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs@@ -97,15 +97,15 @@ impl GroupCustomize for URLGroupController {self.group_ctx.iter_mut_status_groups(|group| {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());if group.id == cell_data.content {- if !group.contains_row(row.id) {+ if !group.contains_row(&row.id) {changeset.inserted_rows.push(InsertedRowPB::new(RowPB::from(row)));group.add_row(row.clone());}- } else if group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ } else if group.contains_row(&row.id) {+ group.remove_row(&row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());}if !changeset.is_empty() {@@ -119,9 +119,9 @@ impl GroupCustomize for URLGroupController {let mut changesets = vec![];self.group_ctx.iter_mut_groups(|group| {let mut changeset = GroupRowsNotificationPB::new(group.id.clone());- if group.contains_row(row.id) {- changeset.deleted_rows.push(row.id.into());- group.remove_row(row.id);+ if group.contains_row(&row.id) {+ group.remove_row(&row.id);+ changeset.deleted_rows.push(row.id.clone().into_inner());}if !changeset.is_empty() {diff --git a/frontend/rust-lib/flowy-database2/src/services/group/entities.rs b/frontend/rust-lib/flowy-database2/src/services/group/entities.rsindex 8354cf2950..27d24b5510 100644--- a/frontend/rust-lib/flowy-database2/src/services/group/entities.rs+++ b/frontend/rust-lib/flowy-database2/src/services/group/entities.rs@@ -143,12 +143,12 @@ impl GroupData {}}- pub fn contains_row(&self, row_id: RowId) -> bool {- self.rows.iter().any(|row| row.id == row_id)+ pub fn contains_row(&self, row_id: &RowId) -> bool {+ self.rows.iter().any(|row| &row.id == row_id)}- pub fn remove_row(&mut self, row_id: RowId) {- match self.rows.iter().position(|row| row.id == row_id) {+ pub fn remove_row(&mut self, row_id: &RowId) {+ match self.rows.iter().position(|row| &row.id == row_id) {None => {},Some(pos) => {self.rows.remove(pos);@@ -177,8 +177,8 @@ impl GroupData {}}- pub fn index_of_row(&self, row_id: RowId) -> Option<usize> {- self.rows.iter().position(|row| row.id == row_id)+ pub fn index_of_row(&self, row_id: &RowId) -> Option<usize> {+ self.rows.iter().position(|row| &row.id == row_id)}pub fn number_of_row(&self) -> usize {diff --git a/frontend/rust-lib/flowy-database2/src/services/sort/controller.rs b/frontend/rust-lib/flowy-database2/src/services/sort/controller.rsindex c67ba85881..34f9e48b74 100644--- a/frontend/rust-lib/flowy-database2/src/services/sort/controller.rs+++ b/frontend/rust-lib/flowy-database2/src/services/sort/controller.rs@@ -118,7 +118,7 @@ impl SortController {return Ok(());}let notification = ReorderSingleRowResult {- row_id: row_id.into(),+ row_id,view_id: self.view_id.clone(),old_index: old_row_index,new_index: new_row_index,@@ -158,7 +158,7 @@ impl SortController {rows.par_sort_by(|left, right| cmp_row(left, right, sort, &field_revs, &self.cell_cache));}rows.iter().enumerate().for_each(|(index, row)| {- self.row_index_cache.insert(row.id, index);+ self.row_index_cache.insert(row.id.clone(), index);});}diff --git a/frontend/rust-lib/flowy-database2/src/services/sort/entities.rs b/frontend/rust-lib/flowy-database2/src/services/sort/entities.rsindex 78f2cfa29d..59e326b0b3 100644--- a/frontend/rust-lib/flowy-database2/src/services/sort/entities.rs+++ b/frontend/rust-lib/flowy-database2/src/services/sort/entities.rs@@ -1,5 +1,6 @@use anyhow::bail;use collab::core::any_map::AnyMapExtension;+use collab_database::rows::RowId;use collab_database::views::{SortMap, SortMapBuilder};use crate::entities::{DeleteSortParams, FieldType};@@ -119,7 +120,7 @@ impl ReorderAllRowsResult {#[derive(Clone)]pub struct ReorderSingleRowResult {pub view_id: String,- pub row_id: i64,+ pub row_id: RowId,pub old_index: usize,pub new_index: usize,}diff --git a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rsindex 5e765f5702..15b8bf83d5 100644--- a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs@@ -104,15 +104,12 @@ impl DatabaseGroupTest {.unwrap();let to_group = groups.get(to_group_index).unwrap();let to_row = to_group.rows.get(to_row_index).unwrap();+ let from_row = RowId::from(from_row.id.clone());+ let to_row = RowId::from(to_row.id.clone());self.editor- .move_group_row(- &self.view_id,- &to_group.group_id,- RowId::from(from_row.id),- Some(RowId::from(to_row.id)),- )+ .move_group_row(&self.view_id, &to_group.group_id, from_row, Some(to_row)).await.unwrap();},@@ -141,7 +138,8 @@ impl DatabaseGroupTest {row_index,} => {let row = self.row_at_index(group_index, row_index).await;- self.editor.delete_row(RowId::from(row.id)).await;+ let row_id = RowId::from(row.id);+ self.editor.delete_row(&row_id).await;},GroupScript::UpdateGroupedCell {from_group_index,diff --git a/frontend/rust-lib/flowy-document2/src/manager.rs b/frontend/rust-lib/flowy-document2/src/manager.rsindex 0645972456..461e68e502 100644--- a/frontend/rust-lib/flowy-document2/src/manager.rs+++ b/frontend/rust-lib/flowy-document2/src/manager.rs@@ -41,10 +41,7 @@ impl DocumentManager {) -> FlowyResult<Arc<Document>> {let collab = self.get_collab_for_doc_id(&doc_id)?;let document = Arc::new(Document::create_with_data(collab, data.0)?);- self- .documents- .write()- .insert(doc_id.clone(), document.clone());+ self.documents.write().insert(doc_id, document.clone());Ok(document)}@@ -65,10 +62,7 @@ impl DocumentManager {.send();}).map_err(|err| FlowyError::internal().context(err))?;- self- .documents- .write()- .insert(doc_id.clone(), document.clone());+ self.documents.write().insert(doc_id, document.clone());Ok(document)}diff --git a/frontend/rust-lib/flowy-document2/tests/document/document_test.rs b/frontend/rust-lib/flowy-document2/tests/document/document_test.rsindex 363fdfc125..d0c2229ee4 100644--- a/frontend/rust-lib/flowy-document2/tests/document/document_test.rs+++ b/frontend/rust-lib/flowy-document2/tests/document/document_test.rs@@ -42,7 +42,7 @@ fn restore_document() {.get_document().unwrap();// close a document- _ = manager.close_document(doc_id.clone());+ _ = manager.close_document(doc_id);assert_eq!(data_b, data.0);}@@ -66,7 +66,7 @@ fn document_apply_insert_action() {let text_block = Block {id: nanoid!(10),ty: "text".to_string(),- parent: page_block.id.clone(),+ parent: page_block.id,children: nanoid!(10),external_id: None,external_type: None,@@ -75,7 +75,7 @@ fn document_apply_insert_action() {let insert_text_action = BlockAction {action: BlockActionType::Insert,payload: BlockActionPayload {- block: text_block.clone(),+ block: text_block,parent_id: None,prev_id: None,},@@ -93,7 +93,7 @@ fn document_apply_insert_action() {.get_document().unwrap();// close a document- _ = manager.close_document(doc_id.clone());+ _ = manager.close_document(doc_id);assert_eq!(data_b, data_a);}@@ -113,7 +113,7 @@ fn document_apply_update_page_action() {let document = manager.open_document(doc_id.clone()).unwrap();let page_block = document.lock().get_block(&data.0.page_id).unwrap();- let mut page_block_clone = page_block.clone();+ let mut page_block_clone = page_block;page_block_clone.data = HashMap::new();page_block_clone.data.insert("delta".to_string(),@@ -134,7 +134,7 @@ fn document_apply_update_page_action() {_ = manager.close_document(doc_id.clone());// re-open the document- let document = manager.open_document(doc_id.clone()).unwrap();+ let document = manager.open_document(doc_id).unwrap();let page_block_new = document.lock().get_block(&data.0.page_id).unwrap();assert_eq!(page_block_old, page_block_new);assert!(page_block_new.data.contains_key("delta"));@@ -160,7 +160,7 @@ fn document_apply_update_action() {let text_block = Block {id: text_block_id.clone(),ty: "text".to_string(),- parent: page_block.id.clone(),+ parent: page_block.id,children: nanoid!(10),external_id: None,external_type: None,@@ -169,7 +169,7 @@ fn document_apply_update_action() {let insert_text_action = BlockAction {action: BlockActionType::Insert,payload: BlockActionPayload {- block: text_block.clone(),+ block: text_block,parent_id: None,prev_id: None,},@@ -192,7 +192,7 @@ fn document_apply_update_action() {let update_text_action = BlockAction {action: BlockActionType::Update,payload: BlockActionPayload {- block: updated_text_block.clone(),+ block: updated_text_block,parent_id: None,prev_id: None,},@@ -206,5 +206,5 @@ fn document_apply_update_action() {let block = document.lock().get_block(&text_block_id).unwrap();assert_eq!(block.data, updated_text_block_data);// close a document- _ = manager.close_document(doc_id.clone());+ _ = manager.close_document(doc_id);}diff --git a/frontend/rust-lib/flowy-document2/tests/document/util.rs b/frontend/rust-lib/flowy-document2/tests/document/util.rsindex a18ae088b0..71da9ffdaa 100644--- a/frontend/rust-lib/flowy-document2/tests/document/util.rs+++ b/frontend/rust-lib/flowy-document2/tests/document/util.rs@@ -1,13 +1,12 @@-use std::sync::Arc;--use collab_persistence::CollabKV;+use collab_persistence::kv::rocks_kv::RocksCollabDB;use flowy_document2::manager::DocumentUser;use parking_lot::Once;+use std::sync::Arc;use tempfile::TempDir;use tracing_subscriber::{fmt::Subscriber, util::SubscriberInitExt, EnvFilter};pub struct FakeUser {- kv: Arc<CollabKV>,+ kv: Arc<RocksCollabDB>,}impl FakeUser {@@ -25,12 +24,12 @@ impl DocumentUser for FakeUser {Ok("1".to_string())}- fn kv_db(&self) -> Result<std::sync::Arc<CollabKV>, flowy_error::FlowyError> {+ fn kv_db(&self) -> Result<std::sync::Arc<RocksCollabDB>, flowy_error::FlowyError> {Ok(self.kv.clone())}}-pub fn db() -> Arc<CollabKV> {+pub fn db() -> Arc<RocksCollabDB> {static START: Once = Once::new();START.call_once(|| {std::env::set_var("RUST_LOG", "collab_persistence=trace");@@ -43,5 +42,5 @@ pub fn db() -> Arc<CollabKV> {let tempdir = TempDir::new().unwrap();let path = tempdir.into_path();- Arc::new(CollabKV::open(path).unwrap())+ Arc::new(RocksCollabDB::open(path).unwrap())}