2022-02-28 21:17:08 -05:00
|
|
|
import 'dart:async';
|
|
|
|
import 'package:dartz/dartz.dart';
|
2023-01-08 12:10:53 +08:00
|
|
|
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
2023-04-04 08:41:16 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder2/trash.pb.dart';
|
2022-02-28 21:17:08 -05:00
|
|
|
|
|
|
|
class TrashService {
|
2022-07-19 14:11:29 +08:00
|
|
|
Future<Either<RepeatedTrashPB, FlowyError>> readTrash() {
|
2022-02-28 21:17:08 -05:00
|
|
|
return FolderEventReadTrash().send();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> putback(String trashId) {
|
2022-07-19 14:11:29 +08:00
|
|
|
final id = TrashIdPB.create()..id = trashId;
|
2022-02-28 21:17:08 -05:00
|
|
|
|
|
|
|
return FolderEventPutbackTrash(id).send();
|
|
|
|
}
|
|
|
|
|
2023-04-04 08:41:16 +08:00
|
|
|
Future<Either<Unit, FlowyError>> deleteViews(List<String> trash) {
|
|
|
|
final items = trash.map((trash) {
|
|
|
|
return TrashIdPB.create()..id = trash;
|
2022-02-28 21:17:08 -05:00
|
|
|
});
|
|
|
|
|
2022-07-19 14:11:29 +08:00
|
|
|
final ids = RepeatedTrashIdPB(items: items);
|
2022-02-28 21:17:08 -05:00
|
|
|
return FolderEventDeleteTrash(ids).send();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> restoreAll() {
|
|
|
|
return FolderEventRestoreAllTrash().send();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Either<Unit, FlowyError>> deleteAll() {
|
|
|
|
return FolderEventDeleteAllTrash().send();
|
|
|
|
}
|
|
|
|
}
|