mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-25 01:50:56 +00:00

* feat: try using folder2 * feat: update * feat: implement handlers * fix: compile errors * chore: add unsafe send + sync * feat: remove unsafe impl * fix: replace folder with foler2 * chore: dart compile errors * test: fix test * test: fix test * test: bypass existing tests * feat: open latest view * chore: fix dart warnings * chore: config notification * fix: folder notification bugs * fix: doesn't open the new view after creating * chore: rename struct * refactor: user id * test: fix test * chore: remove unused user_id * fix: fix read workspace views * chore: rename appflowy data folder * chore: update ref * fix: tauri build
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-folder2/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 payload = ViewIdPB(value: docId);
|
|
return FolderEventCloseView(payload).send();
|
|
}
|
|
}
|