Sfoglia il codice sorgente

Fix issue in tracking all folders

Neeraj Gupta 2 anni fa
parent
commit
a0007ba45a
2 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. 2 2
      lib/core/configuration.dart
  2. 10 6
      lib/ui/backup_folder_selection_page.dart

+ 2 - 2
lib/core/configuration.dart

@@ -395,7 +395,7 @@ class Configuration {
     final allFolders = (await FilesDB.instance.getLatestLocalFiles())
         .map((file) => file.deviceFolder)
         .toList();
-    await _setSelectAllFoldersForBackup(newPaths.length == allFolders.length);
+    await setSelectAllFoldersForBackup(newPaths.length == allFolders.length);
     SyncService.instance.onFoldersSet(newPaths);
     SyncService.instance.sync();
   }
@@ -572,7 +572,7 @@ class Configuration {
     return _preferences.getBool(hasSelectedAllFoldersForBackupKey) ?? false;
   }
 
-  Future<void> _setSelectAllFoldersForBackup(bool value) async {
+  Future<void> setSelectAllFoldersForBackup(bool value) async {
     await _preferences.setBool(hasSelectedAllFoldersForBackupKey, value);
   }
 

+ 10 - 6
lib/ui/backup_folder_selection_page.dart

@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
 import 'package:implicitly_animated_reorderable_list/implicitly_animated_reorderable_list.dart';
 import 'package:implicitly_animated_reorderable_list/transitions.dart';
 import 'package:logging/logging.dart';
+import 'package:photos/core/configuration.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/db/device_files_db.dart';
 import 'package:photos/db/files_db.dart';
@@ -172,14 +173,17 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
                         ? null
                         : () async {
                             Map<String, bool> syncStatus = {};
-                            _allDevicePathIDs.forEach((element) {
-                              syncStatus[element] =
-                                  _selectedDevicePathIDs.contains(element);
-                            });
+                            for (String pathID in _allDevicePathIDs) {
+                              syncStatus[pathID] =
+                                  _selectedDevicePathIDs.contains(pathID);
+                            }
                             await FilesDB.instance
                                 .updateDevicePathSyncStatus(syncStatus);
-                            // await Configuration.instance
-                            //     .setPathsToBackUp(_selectedDevicePathIDs);
+                            await Configuration.instance
+                                .setSelectAllFoldersForBackup(
+                              _allDevicePathIDs.length ==
+                                  _selectedDevicePathIDs.length,
+                            );
                             Bus.instance.fire(BackupFoldersUpdatedEvent());
                             Navigator.of(context).pop();
                           },