Преглед на файлове

Dismiss progress dialog on error

vishnukvmd преди 3 години
родител
ревизия
c87ff10fe4
променени са 1 файла, в които са добавени 16 реда и са изтрити 11 реда
  1. 16 11
      lib/ui/settings/backup_section_widget.dart

+ 16 - 11
lib/ui/settings/backup_section_widget.dart

@@ -132,18 +132,23 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
           onTap: () async {
             final dialog = createProgressDialog(context, "calculating...");
             await dialog.show();
-            final duplicates =
-                await DeduplicationService.instance.getDuplicateFiles();
-            await dialog.hide();
-            if (duplicates.isEmpty) {
-              showErrorDialog(context, "✨ no duplicates",
-                  "you've no duplicate files that can be cleared");
-            } else {
-              DeduplicationResult result =
-                  await routeToPage(context, DeduplicatePage(duplicates));
-              if (result != null) {
-                _showDuplicateFilesDeletedDialog(result);
+            try {
+              final duplicates =
+                  await DeduplicationService.instance.getDuplicateFiles();
+              await dialog.hide();
+              if (duplicates.isEmpty) {
+                showErrorDialog(context, "✨ no duplicates",
+                    "you've no duplicate files that can be cleared");
+              } else {
+                DeduplicationResult result =
+                    await routeToPage(context, DeduplicatePage(duplicates));
+                if (result != null) {
+                  _showDuplicateFilesDeletedDialog(result);
+                }
               }
+            } catch (e) {
+              await dialog.hide();
+              showGenericErrorDialog(context);
             }
           },
           child: SettingsTextItem(