Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Finish backup settings handoff after folder selection

Prateek Sunalb2c3ff64fafd
diff --git a/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart b/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart
index 8d3167b063..164bbaef3c 100644
--- a/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart
+++ b/mobile/apps/photos/lib/ui/common/backup_flow_helper.dart
@@ -18,6 +18,7 @@ import "package:photos/utils/navigation_util.dart";
Future<void> handleBackupEntryFlow(
BuildContext context, {
Widget Function()? onFirstImportComplete,
+ Widget Function()? postSelectionDestination,
}) async {
final state = await permissionService.requestPhotoMangerPermissions();
if (state == PermissionState.authorized || state == PermissionState.limited) {
@@ -33,8 +34,9 @@ Future<void> handleBackupEntryFlow(
// Wait for initial sync, then proceed to folder selection
await routeToPage(
context,
- const LoadingPhotosWidget(
+ LoadingPhotosWidget(
isOnboardingFlow: false,
+ onFolderSelectionComplete: postSelectionDestination,
),
);
} else {
diff --git a/mobile/apps/photos/lib/ui/home/loading_photos_widget.dart b/mobile/apps/photos/lib/ui/home/loading_photos_widget.dart
index 8ae4781ad4..e0f1c6697d 100644
--- a/mobile/apps/photos/lib/ui/home/loading_photos_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/loading_photos_widget.dart
@@ -18,10 +18,12 @@ import 'package:photos/utils/navigation_util.dart';
class LoadingPhotosWidget extends StatefulWidget {
final bool isOnboardingFlow;
+ final Widget Function()? onFolderSelectionComplete;
const LoadingPhotosWidget({
super.key,
this.isOnboardingFlow = true,
+ this.onFolderSelectionComplete,
});
@override
@@ -54,24 +56,7 @@ class _LoadingPhotosWidgetState extends State<LoadingPhotosWidget> {
if (permissionService.hasGrantedLimitedPermissions()) {
// Do nothing, let HomeWidget refresh
} else {
- if (widget.isOnboardingFlow) {
- // ignore: unawaited_futures
- routeToPage(
- context,
- const BackupFolderSelectionPage(
- isOnboarding: true,
- isFirstBackup: true,
- ),
- );
- } else {
- replacePage(
- context,
- const BackupFolderSelectionPage(
- isOnboarding: false,
- isFirstBackup: false,
- ),
- );
- }
+ await _goToFolderSelection();
}
}
});
@@ -95,6 +80,42 @@ class _LoadingPhotosWidgetState extends State<LoadingPhotosWidget> {
});
}
+ Future<void> _goToFolderSelection() async {
+ if (widget.isOnboardingFlow) {
+ // ignore: unawaited_futures
+ routeToPage(
+ context,
+ const BackupFolderSelectionPage(
+ isOnboarding: true,
+ isFirstBackup: true,
+ ),
+ );
+ return;
+ }
+
+ final selectionResult = await routeToPage<bool>(
+ context,
+ const BackupFolderSelectionPage(
+ isOnboarding: false,
+ isFirstBackup: false,
+ ),
+ );
+
+ if (!mounted) {
+ return;
+ }
+
+ if (widget.onFolderSelectionComplete != null) {
+ replacePage(
+ context,
+ widget.onFolderSelectionComplete!(),
+ result: selectionResult,
+ );
+ } else {
+ Navigator.of(context).pop(selectionResult);
+ }
+ }
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
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.dart
index 0084034502..25f73527c6 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
@@ -45,6 +45,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
onFirstImportComplete: () => const BackupFolderSelectionPage(
isFirstBackup: false,
),
+ postSelectionDestination: () => const BackupSettingsScreen(),
);
},
),
@@ -75,6 +76,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
await handleBackupEntryFlow(
context,
onFirstImportComplete: () => const BackupSettingsScreen(),
+ postSelectionDestination: () => const BackupSettingsScreen(),
);
},
),