Pārlūkot izejas kodu

go to previous screen when file is deleted from trash

Neeraj Gupta 3 gadi atpakaļ
vecāks
revīzija
dff56f7f72
2 mainītis faili ar 9 papildinājumiem un 6 dzēšanām
  1. 3 2
      lib/ui/fading_bottom_bar.dart
  2. 6 4
      lib/utils/delete_file_util.dart

+ 3 - 2
lib/ui/fading_bottom_bar.dart

@@ -197,8 +197,9 @@ class FadingBottomBarState extends State<FadingBottomBar> {
             onPressed: () async {
             onPressed: () async {
               final trashedFile = <TrashFile>[];
               final trashedFile = <TrashFile>[];
               trashedFile.add(widget.file);
               trashedFile.add(widget.file);
-              await deleteFromTrash(context, trashedFile);
-              Navigator.pop(context);
+              if (await deleteFromTrash(context, trashedFile) == true) {
+                Navigator.pop(context);
+              }
             },
             },
           ),
           ),
         ),
         ),

+ 6 - 4
lib/utils/delete_file_util.dart

@@ -197,13 +197,13 @@ Future<void> deleteFilesOnDeviceOnly(
   await dialog.hide();
   await dialog.hide();
 }
 }
 
 
-Future<void> deleteFromTrash(
+Future<bool> deleteFromTrash(
     BuildContext context, List<TrashFile> files) async {
     BuildContext context, List<TrashFile> files) async {
   final result = await showChoiceDialog(context, "delete permanently?",
   final result = await showChoiceDialog(context, "delete permanently?",
       "the files will be permanently removed from your ente account",
       "the files will be permanently removed from your ente account",
       firstAction: "delete", actionType: ActionType.critical);
       firstAction: "delete", actionType: ActionType.critical);
-  if( result != DialogUserChoice.firstChoice) {
-    return;
+  if (result != DialogUserChoice.firstChoice) {
+    return false;
   }
   }
   final dialog = createProgressDialog(context, "permanently deleting...");
   final dialog = createProgressDialog(context, "permanently deleting...");
   await dialog.show();
   await dialog.show();
@@ -212,10 +212,12 @@ Future<void> deleteFromTrash(
     showToast("successfully deleted");
     showToast("successfully deleted");
     await dialog.hide();
     await dialog.hide();
     Bus.instance.fire(FilesUpdatedEvent(files, type: EventType.deleted));
     Bus.instance.fire(FilesUpdatedEvent(files, type: EventType.deleted));
+    return true;
   } catch (e, s) {
   } catch (e, s) {
-    Logger("TrashUtil").info("failed to delete from trash", e, s);
+    _logger.info("failed to delete from trash", e, s);
     await dialog.hide();
     await dialog.hide();
     await showGenericErrorDialog(context);
     await showGenericErrorDialog(context);
+    return false;
   }
   }
 }
 }