2022-05-11 20:38:07 +08:00
|
|
|
import 'dart:async';
|
2024-01-24 23:59:45 +08:00
|
|
|
|
2023-01-08 12:10:53 +08:00
|
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
2024-02-24 20:54:10 +07:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
|
2023-01-08 12:10:53 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
2024-02-24 20:54:10 +07:00
|
|
|
import 'package:appflowy_result/appflowy_result.dart';
|
2022-07-14 20:40:01 +08:00
|
|
|
|
2024-02-25 18:38:18 +08:00
|
|
|
import '../application/cell/cell_controller.dart';
|
2022-05-11 20:38:07 +08:00
|
|
|
|
2023-02-26 16:27:17 +08:00
|
|
|
class CellBackendService {
|
|
|
|
CellBackendService();
|
2022-05-11 20:38:07 +08:00
|
|
|
|
2024-02-24 20:54:10 +07:00
|
|
|
static Future<FlowyResult<void, FlowyError>> updateCell({
|
2024-01-24 23:59:45 +08:00
|
|
|
required String viewId,
|
|
|
|
required CellContext cellContext,
|
2022-05-11 20:38:07 +08:00
|
|
|
required String data,
|
|
|
|
}) {
|
2024-01-24 23:59:45 +08:00
|
|
|
final payload = CellChangesetPB()
|
|
|
|
..viewId = viewId
|
2023-06-04 09:28:13 +08:00
|
|
|
..fieldId = cellContext.fieldId
|
|
|
|
..rowId = cellContext.rowId
|
2023-04-28 14:08:53 +08:00
|
|
|
..cellChangeset = data;
|
2023-01-31 08:28:31 +08:00
|
|
|
return DatabaseEventUpdateCell(payload).send();
|
2022-05-11 20:38:07 +08:00
|
|
|
}
|
|
|
|
|
2024-02-24 20:54:10 +07:00
|
|
|
static Future<FlowyResult<CellPB, FlowyError>> getCell({
|
2024-01-24 23:59:45 +08:00
|
|
|
required String viewId,
|
|
|
|
required CellContext cellContext,
|
2022-05-11 20:38:07 +08:00
|
|
|
}) {
|
2024-01-24 23:59:45 +08:00
|
|
|
final payload = CellIdPB()
|
|
|
|
..viewId = viewId
|
2023-06-04 09:28:13 +08:00
|
|
|
..fieldId = cellContext.fieldId
|
|
|
|
..rowId = cellContext.rowId;
|
2023-01-31 08:28:31 +08:00
|
|
|
return DatabaseEventGetCell(payload).send();
|
2022-05-11 20:38:07 +08:00
|
|
|
}
|
|
|
|
}
|