| 
									
										
										
										
											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'; | 
					
						
							|  |  |  | import 'package:appflowy_backend/protobuf/flowy-folder/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-01-08 12:10:53 +08:00
										 |  |  |   Future<Either<Unit, FlowyError>> deleteViews( | 
					
						
							|  |  |  |       List<Tuple2<String, TrashType>> trashList) { | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |     final items = trashList.map((trash) { | 
					
						
							| 
									
										
										
										
											2022-07-19 14:11:29 +08:00
										 |  |  |       return TrashIdPB.create() | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |         ..id = trash.value1 | 
					
						
							|  |  |  |         ..ty = trash.value2; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |