π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: update the backup flow helper to mimic previous behaviour
Prateek Sunal962d41814c79
diff --git a/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart b/mobile/apps/photos/lib/ui/common/backup_flow_helper.dartindex 644891b649..9e6853f5ee 100644--- a/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart+++ b/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart@@ -5,8 +5,6 @@ import "package:logging/logging.dart";import "package:photo_manager/photo_manager.dart";import "package:photos/l10n/l10n.dart";import "package:photos/service_locator.dart";-import "package:photos/services/sync/local_sync_service.dart";-import "package:photos/services/sync/sync_service.dart";import "package:photos/ui/home/loading_photos_widget.dart";import "package:photos/ui/settings/backup/backup_folder_selection_page.dart";import "package:photos/utils/dialog_util.dart";@@ -18,31 +16,36 @@ import "package:photos/utils/navigation_util.dart";/// selection.Future<void> handleBackupEntryFlow(BuildContext context, {- Widget Function()? onFirstImportComplete,+ bool isFirstBackup = false,}) async {+ PermissionState state;try {- final PermissionState state =- await permissionService.requestPhotoMangerPermissions();+ // Always fetch fresh permission state from the platform instead of relying+ // on cached prefs; this avoids stale reads when users change OS settings.+ state = await permissionService.requestPhotoMangerPermissions();await permissionService.onUpdatePermission(state);- } on Exception catch (e, s) {+ } catch (e, s) {Logger("BackupEntryFlow").severe(- "Failed to request permission: ${e.toString()}",+ "Failed to request permission",e,s,);return;}- if (!permissionService.hasGrantedFullPermission()) {+ if (state != PermissionState.authorized && state != PermissionState.limited) {if (!context.mounted) {return;}+if (Platform.isAndroid) {+ // On Android, we can only direct users to system settings for upgrades.await PhotoManager.openSetting();return;}- final bool hasGrantedLimit =- permissionService.hasGrantedLimitedPermissions();++ // On iOS, offer a path to either open settings or expand limited access.+ final bool hasLimited = state == PermissionState.limited;await showChoiceActionSheet(context,title: context.l10n.preserveMore,@@ -52,39 +55,35 @@ Future<void> handleBackupEntryFlow(await PhotoManager.openSetting();},secondButtonLabel:- hasGrantedLimit ? context.l10n.selectMorePhotos : context.l10n.cancel,- secondButtonOnTap: hasGrantedLimit- ? () async {- await PhotoManager.presentLimited();- }- : null,+ hasLimited ? context.l10n.selectMorePhotos : context.l10n.cancel,+ secondButtonOnTap: () async {+ if (hasLimited) {+ await PhotoManager.presentLimited();+ }+ },);return;}- SyncService.instance.onPermissionGranted().ignore();- // Note: Don't fire PermissionGrantedEvent before navigation - it causes- // home_widget to show its own LoadingPhotosWidget while we navigate to ours,- // resulting in duplicate BackupFolderSelectionPage navigations.if (!context.mounted) {return;}- final Widget Function() targetBuilder = onFirstImportComplete ??- () => const BackupFolderSelectionPage(- isFirstBackup: false,- );- final shouldWaitForFirstImport =- !LocalSyncService.instance.hasCompletedFirstImport();- if (shouldWaitForFirstImport) {- // Wait for initial sync, then proceed to folder selection++ final bool didSkipPermissionOnboarding =+ backupPreferenceService.hasSkippedOnboardingPermission;+ // If the user skipped permission onboarding, still show the loading screen+ // before navigating to folder selection; otherwise proceed directly.+ if (didSkipPermissionOnboarding) {await routeToPage(context,const LoadingPhotosWidget(isOnboardingFlow: false),);- } else {- await routeToPage(- context,- targetBuilder(),- );}++ await routeToPage(+ context,+ BackupFolderSelectionPage(+ isFirstBackup: isFirstBackup,+ ),+ );}diff --git a/mobile/apps/photos/lib/ui/home/start_backup_hook_widget.dart b/mobile/apps/photos/lib/ui/home/start_backup_hook_widget.dartindex 85f241a7b4..a1dcf6e4b5 100644--- a/mobile/apps/photos/lib/ui/home/start_backup_hook_widget.dart+++ b/mobile/apps/photos/lib/ui/home/start_backup_hook_widget.dart@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';import 'package:photos/generated/l10n.dart';import 'package:photos/ui/common/backup_flow_helper.dart';import 'package:photos/ui/common/gradient_button.dart';-import 'package:photos/ui/settings/backup/backup_folder_selection_page.dart';class StartBackupHookWidget extends StatelessWidget {final Widget headerWidget;@@ -47,10 +46,7 @@ class StartBackupHookWidget extends StatelessWidget {onTap: () async {await handleBackupEntryFlow(context,- onFirstImportComplete: () =>- const BackupFolderSelectionPage(- isFirstBackup: true,- ),+ isFirstBackup: true,);},text: AppLocalizations.of(context).startBackup,diff --git a/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart b/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dartindex 8714f02438..0c02862dd9 100644--- a/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart+++ b/mobile/apps/photos/lib/ui/settings/backup/backup_section_widget.dart@@ -5,7 +5,6 @@ import 'package:photos/ui/common/backup_flow_helper.dart';import "package:photos/ui/components/captioned_text_widget.dart";import 'package:photos/ui/components/expandable_menu_item_widget.dart';import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';-import 'package:photos/ui/settings/backup/backup_folder_selection_page.dart';import "package:photos/ui/settings/backup/backup_settings_screen.dart";import "package:photos/ui/settings/backup/backup_status_screen.dart";import "package:photos/ui/settings/backup/free_space_options.dart";@@ -42,9 +41,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {onTap: () async {await handleBackupEntryFlow(context,- onFirstImportComplete: () => const BackupFolderSelectionPage(- isFirstBackup: false,- ),+ isFirstBackup: false,);},),