π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Revert "Refine local download prompt handling"
ashilkn3760848e974a
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dartindex e8ef7a601a..32c07dc89b 100644--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart@@ -10,6 +10,7 @@ import 'package:logging/logging.dart';import 'package:media_extension/media_extension.dart';import "package:photos/core/configuration.dart";import "package:photos/core/event_bus.dart";+import "package:photos/db/files_db.dart";import "package:photos/events/guest_view_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";@@ -62,6 +63,12 @@ class FileAppBar extends StatefulWidget {FileAppBarState createState() => FileAppBarState();}+class _LocalFileLocation {+ final String locationName;++ const _LocalFileLocation(this.locationName);+}+class FileAppBarState extends State<FileAppBar> {final _logger = Logger("FadingAppBar");final List<Widget> _actions = [];@@ -619,15 +626,15 @@ class FileAppBarState extends State<FileAppBar> {}Future<void> _download(EnteFile file) async {- final String? localFileLocationName =+ final _LocalFileLocation? localFileLocation =await _getExistingLocalFileLocation(file);- if (localFileLocationName != null && mounted) {+ if (localFileLocation != null && mounted) {final actionResult = await showChoiceActionSheet(context,title: "Already available on device",body: Platform.isAndroid- ? "You can find this file in the \"$localFileLocationName\" folder. Download it again?"- : "You can find this file in the \"$localFileLocationName\" album. Download it again?",+ ? "You can find this file in the \"${localFileLocation.locationName}\" folder. Download it again?"+ : "You can find this file in the \"${localFileLocation.locationName}\" album. Download it again?",firstButtonLabel: "Download anyway",secondButtonLabel: "Cancel",);@@ -656,7 +663,7 @@ class FileAppBarState extends State<FileAppBar> {}}- Future<String?> _getExistingLocalFileLocation(+ Future<_LocalFileLocation?> _getExistingLocalFileLocation(EnteFile file,) async {if (file.localID == null || file.localID!.isEmpty) {@@ -665,6 +672,13 @@ class FileAppBarState extends State<FileAppBar> {final asset = await file.getAsset;if (asset == null || !(await asset.exists)) {+ _logger.info(+ "Removing stale localID reference before download for ${file.tag}",+ );+ file.localID = null;+ if (file.generatedID != null) {+ unawaited(FilesDB.instance.update(file));+ }return null;}@@ -681,7 +695,7 @@ class FileAppBarState extends State<FileAppBar> {} else {folderName = "Recent";}- return folderName;+ return _LocalFileLocation(folderName);}final String albumSource = deviceFolder.isNotEmpty@@ -689,7 +703,7 @@ class FileAppBarState extends State<FileAppBar> {: relativePath.isNotEmpty? _getLastPathSegment(relativePath): "Recents";- return albumSource;+ return _LocalFileLocation(albumSource);}String _getLastPathSegment(String path) {