Browse Source

Fix: Show backup folder option during onboarding

Neeraj Gupta 2 years ago
parent
commit
74c26628d6
2 changed files with 9 additions and 5 deletions
  1. 7 3
      lib/services/local_sync_service.dart
  2. 2 2
      lib/ui/backup_folder_selection_page.dart

+ 7 - 3
lib/services/local_sync_service.dart

@@ -125,7 +125,7 @@ class LocalSyncService {
         !_prefs.getBool(kHasCompletedFirstImportKey)) {
       await _prefs.setBool(kHasCompletedFirstImportKey, true);
       // mark device collection has imported on first import
-      await _refreshDeviceFolderCountAndCover();
+      await _refreshDeviceFolderCountAndCover(isFirstSync: true);
       await _prefs.setBool(hasImportedDeviceCollections, true);
       _logger.fine("first gallery import finished");
       Bus.instance
@@ -138,14 +138,18 @@ class LocalSyncService {
     _existingSync = null;
   }
 
-  Future<bool> _refreshDeviceFolderCountAndCover() async {
+  Future<bool> _refreshDeviceFolderCountAndCover({
+    bool isFirstSync = false,
+  }) async {
     final List<Tuple2<AssetPathEntity, String>> result =
         await getDeviceFolderWithCountAndCoverID();
     final bool hasUpdated = await _db.updateDeviceCoverWithCount(
       result,
       shouldBackup: Configuration.instance.hasSelectedAllFoldersForBackup(),
     );
-    if (hasUpdated) {
+    // do not fire UI update event during first sync. Otherwise the next screen
+    // to shop the backup folder is skipped
+    if (hasUpdated && !isFirstSync) {
       Bus.instance.fire(BackupFoldersUpdatedEvent());
     }
     // migrate the backed up folder settings after first import is done remove

+ 2 - 2
lib/ui/backup_folder_selection_page.dart

@@ -180,12 +180,12 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
                               syncStatus[pathID] =
                                   _selectedDevicePathIDs.contains(pathID);
                             }
-                            await RemoteSyncService.instance
-                                .updateDeviceFolderSyncStatus(syncStatus);
                             await Configuration.instance
                                 .setHasSelectedAnyBackupFolder(
                               _selectedDevicePathIDs.isNotEmpty,
                             );
+                            await RemoteSyncService.instance
+                                .updateDeviceFolderSyncStatus(syncStatus);
                             await Configuration.instance
                                 .setSelectAllFoldersForBackup(
                               _allDevicePathIDs.length ==