π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix video edit delete navigation
Neeraj Guptac3c23ea888dc
diff --git a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart b/mobile/apps/photos/lib/ui/actions/file/file_actions.dartindex 262884e8d4..ae61010f3b 100644--- a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart+++ b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart@@ -40,8 +40,10 @@ Future<void> showSingleFileDeleteSheet();return;}- await deleteFilesOnDeviceOnly(context, [file]);- if (onFileRemoved != null && (isLocalOnly || isLocalOnlyContext)) {+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);+ if (deletedFiles.isNotEmpty &&+ onFileRemoved != null &&+ (isLocalOnly || isLocalOnlyContext)) {onFileRemoved(file);}return;@@ -105,11 +107,13 @@ Future<void> showSingleFileDeleteSheet(shouldSurfaceExecutionStates: false,isInAlert: true,onTap: () async {- await deleteFilesOnDeviceOnly(context, [file]);+ final deletedFiles = await deleteFilesOnDeviceOnly(context, [file]);// Remove from viewer if:// 1. File is local-only (no remote copy), OR// 2. We're in a local-only context (device folder - file disappears from this view)- if (onFileRemoved != null && (isLocalOnly || isLocalOnlyContext)) {+ if (deletedFiles.isNotEmpty &&+ onFileRemoved != null &&+ (isLocalOnly || isLocalOnlyContext)) {onFileRemoved(file);}},diff --git a/mobile/apps/photos/lib/ui/tools/editor/video_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/video_editor_page.dartindex 56c9807c5e..a10fb47d2a 100644--- a/mobile/apps/photos/lib/ui/tools/editor/video_editor_page.dart+++ b/mobile/apps/photos/lib/ui/tools/editor/video_editor_page.dart@@ -590,7 +590,7 @@ class _VideoEditorPageState extends State<VideoEditorPage> {SyncService.instance.sync().ignore();showShortToast(context, AppLocalizations.of(context).editsSaved);- final files = widget.detailPageConfig.files;+ final files = List<EnteFile>.of(widget.detailPageConfig.files);// the index could be -1 if the files fetched doesn't contain the newly// edited files@@ -598,8 +598,17 @@ class _VideoEditorPageState extends State<VideoEditorPage> {(file) => file.generatedID == newFile.generatedID,);if (selectionIndex == -1) {- files.add(newFile);- selectionIndex = files.length - 1;+ final fallbackIndex = min(+ max(widget.detailPageConfig.selectedIndex, 0),+ files.length,+ );+ final originalIndex = widget.file.generatedID == null+ ? -1+ : files.indexWhere(+ (file) => file.generatedID == widget.file.generatedID,+ );+ selectionIndex = originalIndex == -1 ? fallbackIndex : originalIndex;+ files.insert(selectionIndex, newFile);}Navigator.of(dialogKey.currentContext!).pop('dialog');diff --git a/mobile/apps/photos/lib/utils/delete_file_util.dart b/mobile/apps/photos/lib/utils/delete_file_util.dartindex c88d2dade6..89b7e5fc4a 100644--- a/mobile/apps/photos/lib/utils/delete_file_util.dart+++ b/mobile/apps/photos/lib/utils/delete_file_util.dart@@ -197,7 +197,7 @@ Future<void> deleteFilesFromRemoteOnly(RemoteSyncService.instance.sync(silently: true);}-Future<void> deleteFilesOnDeviceOnly(+Future<List<EnteFile>> deleteFilesOnDeviceOnly(BuildContext context,List<EnteFile> files,) async {@@ -226,7 +226,7 @@ Future<void> deleteFilesOnDeviceOnly(if (hasLocalOnlyFiles && Platform.isAndroid && !isLocalGalleryMode) {final shouldProceed = await shouldProceedWithDeletion(context);if (!shouldProceed) {- return;+ return const [];}}Set<String> deletedIDs = <String>{};@@ -262,6 +262,7 @@ Future<void> deleteFilesOnDeviceOnly(),);}+ return deletedFiles;}Future<bool> deleteFromTrash(BuildContext context, List<EnteFile> files) async {