mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-18 14:36:02 +00:00

* refactor: rename structs * chore: read database id from view * chore: fix open database error because of create a database view for database id * chore: fix tests * chore: rename datbase id to view id in flutter * refactor: move grid and board to database view folder * refactor: rename functions * refactor: move calender to datbase view folder * refactor: rename app_flowy to appflowy_flutter * chore: reanming * chore: fix freeze gen * chore: remove todos * refactor: view process events * chore: add link database test * chore: just open view if there is opened database
43 lines
1.3 KiB
Dart
43 lines
1.3 KiB
Dart
import 'package:dartz/dartz.dart';
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-document/entities.pb.dart';
|
|
|
|
class DocumentService {
|
|
Future<Either<DocumentDataPB, FlowyError>> openDocument({
|
|
required ViewPB view,
|
|
}) async {
|
|
await FolderEventSetLatestView(ViewIdPB(value: view.id)).send();
|
|
|
|
final payload = OpenDocumentPayloadPB()
|
|
..documentId = view.id
|
|
..version = DocumentVersionPB.V1;
|
|
// switch (view.dataFormat) {
|
|
// case ViewDataFormatPB.DeltaFormat:
|
|
// payload.documentVersion = DocumentVersionPB.V0;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
|
|
return DocumentEventGetDocument(payload).send();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> applyEdit({
|
|
required String docId,
|
|
required String operations,
|
|
}) {
|
|
final payload = EditPayloadPB.create()
|
|
..docId = docId
|
|
..operations = operations;
|
|
return DocumentEventApplyEdit(payload).send();
|
|
}
|
|
|
|
Future<Either<Unit, FlowyError>> closeDocument({required String docId}) {
|
|
final request = ViewIdPB(value: docId);
|
|
return FolderEventCloseView(request).send();
|
|
}
|
|
}
|