|
@@ -12,7 +12,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
|
import 'package:collection/collection.dart';
|
|
import 'package:collection/collection.dart';
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
import 'package:dartz/dartz.dart';
|
|
import 'package:dartz/dartz.dart';
|
|
-import 'database_service.dart';
|
|
|
|
|
|
+import 'database_view_service.dart';
|
|
import 'defines.dart';
|
|
import 'defines.dart';
|
|
import 'layout/layout_setting_listener.dart';
|
|
import 'layout/layout_setting_listener.dart';
|
|
import 'row/row_cache.dart';
|
|
import 'row/row_cache.dart';
|
|
@@ -67,7 +67,7 @@ class DatabaseCallbacks {
|
|
|
|
|
|
class DatabaseController {
|
|
class DatabaseController {
|
|
final String viewId;
|
|
final String viewId;
|
|
- final DatabaseBackendService _databaseBackendSvc;
|
|
|
|
|
|
+ final DatabaseViewBackendService _databaseViewBackendSvc;
|
|
final FieldController fieldController;
|
|
final FieldController fieldController;
|
|
late DatabaseViewCache _viewCache;
|
|
late DatabaseViewCache _viewCache;
|
|
final LayoutTypePB layoutType;
|
|
final LayoutTypePB layoutType;
|
|
@@ -87,7 +87,7 @@ class DatabaseController {
|
|
|
|
|
|
DatabaseController({required ViewPB view, required this.layoutType})
|
|
DatabaseController({required ViewPB view, required this.layoutType})
|
|
: viewId = view.id,
|
|
: viewId = view.id,
|
|
- _databaseBackendSvc = DatabaseBackendService(viewId: view.id),
|
|
|
|
|
|
+ _databaseViewBackendSvc = DatabaseViewBackendService(viewId: view.id),
|
|
fieldController = FieldController(viewId: view.id),
|
|
fieldController = FieldController(viewId: view.id),
|
|
groupListener = DatabaseGroupListener(view.id),
|
|
groupListener = DatabaseGroupListener(view.id),
|
|
layoutListener = DatabaseLayoutListener(view.id) {
|
|
layoutListener = DatabaseLayoutListener(view.id) {
|
|
@@ -112,7 +112,7 @@ class DatabaseController {
|
|
}
|
|
}
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> open() async {
|
|
Future<Either<Unit, FlowyError>> open() async {
|
|
- return _databaseBackendSvc.openGrid().then((result) {
|
|
|
|
|
|
+ return _databaseViewBackendSvc.openGrid().then((result) {
|
|
return result.fold(
|
|
return result.fold(
|
|
(database) async {
|
|
(database) async {
|
|
_databaseCallbacks?.onDatabaseChanged?.call(database);
|
|
_databaseCallbacks?.onDatabaseChanged?.call(database);
|
|
@@ -152,7 +152,7 @@ class DatabaseController {
|
|
cellDataByFieldId = rowBuilder.build();
|
|
cellDataByFieldId = rowBuilder.build();
|
|
}
|
|
}
|
|
|
|
|
|
- return _databaseBackendSvc.createRow(
|
|
|
|
|
|
+ return _databaseViewBackendSvc.createRow(
|
|
startRowId: startRowId,
|
|
startRowId: startRowId,
|
|
groupId: groupId,
|
|
groupId: groupId,
|
|
cellDataByFieldId: cellDataByFieldId,
|
|
cellDataByFieldId: cellDataByFieldId,
|
|
@@ -161,7 +161,7 @@ class DatabaseController {
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> moveRow(RowPB fromRow,
|
|
Future<Either<Unit, FlowyError>> moveRow(RowPB fromRow,
|
|
{RowPB? toRow, String? groupId}) {
|
|
{RowPB? toRow, String? groupId}) {
|
|
- return _databaseBackendSvc.moveRow(
|
|
|
|
|
|
+ return _databaseViewBackendSvc.moveRow(
|
|
fromRowId: fromRow.id,
|
|
fromRowId: fromRow.id,
|
|
toGroupId: groupId,
|
|
toGroupId: groupId,
|
|
toRowId: toRow?.id,
|
|
toRowId: toRow?.id,
|
|
@@ -170,7 +170,7 @@ class DatabaseController {
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> moveGroup(
|
|
Future<Either<Unit, FlowyError>> moveGroup(
|
|
{required String fromGroupId, required String toGroupId}) {
|
|
{required String fromGroupId, required String toGroupId}) {
|
|
- return _databaseBackendSvc.moveGroup(
|
|
|
|
|
|
+ return _databaseViewBackendSvc.moveGroup(
|
|
fromGroupId: fromGroupId,
|
|
fromGroupId: fromGroupId,
|
|
toGroupId: toGroupId,
|
|
toGroupId: toGroupId,
|
|
);
|
|
);
|
|
@@ -178,7 +178,7 @@ class DatabaseController {
|
|
|
|
|
|
Future<void> updateCalenderLayoutSetting(
|
|
Future<void> updateCalenderLayoutSetting(
|
|
CalendarLayoutSettingsPB layoutSetting) async {
|
|
CalendarLayoutSettingsPB layoutSetting) async {
|
|
- await _databaseBackendSvc
|
|
|
|
|
|
+ await _databaseViewBackendSvc
|
|
.updateLayoutSetting(calendarLayoutSetting: layoutSetting)
|
|
.updateLayoutSetting(calendarLayoutSetting: layoutSetting)
|
|
.then((result) {
|
|
.then((result) {
|
|
result.fold((l) => null, (r) => Log.error(r));
|
|
result.fold((l) => null, (r) => Log.error(r));
|
|
@@ -186,13 +186,13 @@ class DatabaseController {
|
|
}
|
|
}
|
|
|
|
|
|
Future<void> dispose() async {
|
|
Future<void> dispose() async {
|
|
- await _databaseBackendSvc.closeView();
|
|
|
|
|
|
+ await _databaseViewBackendSvc.closeView();
|
|
await fieldController.dispose();
|
|
await fieldController.dispose();
|
|
await groupListener.stop();
|
|
await groupListener.stop();
|
|
}
|
|
}
|
|
|
|
|
|
Future<void> _loadGroups() async {
|
|
Future<void> _loadGroups() async {
|
|
- final result = await _databaseBackendSvc.loadGroups();
|
|
|
|
|
|
+ final result = await _databaseViewBackendSvc.loadGroups();
|
|
return Future(
|
|
return Future(
|
|
() => result.fold(
|
|
() => result.fold(
|
|
(groups) {
|
|
(groups) {
|
|
@@ -204,7 +204,7 @@ class DatabaseController {
|
|
}
|
|
}
|
|
|
|
|
|
Future<void> _loadLayoutSetting() async {
|
|
Future<void> _loadLayoutSetting() async {
|
|
- _databaseBackendSvc.getLayoutSetting(layoutType).then((result) {
|
|
|
|
|
|
+ _databaseViewBackendSvc.getLayoutSetting(layoutType).then((result) {
|
|
result.fold(
|
|
result.fold(
|
|
(l) {
|
|
(l) {
|
|
_layoutCallbacks?.onLoadLayout(l);
|
|
_layoutCallbacks?.onLoadLayout(l);
|