| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  | import 'dart:async'; | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-12-31 07:29:40 +08:00
										 |  |  | import 'package:appflowy_backend/protobuf/flowy-folder/trash.pb.dart'; | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  | import 'package:appflowy_result/appflowy_result.dart'; | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | class TrashService { | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  |   Future<FlowyResult<RepeatedTrashPB, FlowyError>> readTrash() { | 
					
						
							| 
									
										
										
										
											2023-12-24 07:44:08 +08:00
										 |  |  |     return FolderEventListTrashItems().send(); | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  |   Future<FlowyResult<void, 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-24 07:44:08 +08:00
										 |  |  |     return FolderEventRestoreTrashItem(id).send(); | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  |   Future<FlowyResult<void, FlowyError>> deleteViews(List<String> trash) { | 
					
						
							| 
									
										
										
										
											2023-04-04 08:41:16 +08:00
										 |  |  |     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); | 
					
						
							| 
									
										
										
										
											2023-12-24 07:44:08 +08:00
										 |  |  |     return FolderEventPermanentlyDeleteTrashItem(ids).send(); | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  |   Future<FlowyResult<void, FlowyError>> restoreAll() { | 
					
						
							| 
									
										
										
										
											2023-12-24 07:44:08 +08:00
										 |  |  |     return FolderEventRecoverAllTrashItems().send(); | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-24 20:54:10 +07:00
										 |  |  |   Future<FlowyResult<void, FlowyError>> deleteAll() { | 
					
						
							| 
									
										
										
										
											2023-12-24 07:44:08 +08:00
										 |  |  |     return FolderEventPermanentlyDeleteAllTrashItem().send(); | 
					
						
							| 
									
										
										
										
											2022-02-28 21:17:08 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | } |