Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix inconsistent behavior when deleting from Ente

Prateek Sunald57807ffef0d
diff --git a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
index 513d93b6f8..1aa4f3de26 100644
--- a/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
+++ b/mobile/apps/photos/lib/ui/actions/file/file_actions.dart
@@ -22,6 +22,7 @@ Future<void> showSingleFileDeleteSheet(
BuildContext context,
EnteFile file, {
Function(EnteFile)? onFileRemoved,
+ bool isLocalOnlyContext = false,
}) async {
final List<ButtonWidget> buttons = [];
final String fileType = file.fileType == FileType.video
@@ -62,7 +63,10 @@ Future<void> showSingleFileDeleteSheet(
onTap: () async {
await deleteFilesFromRemoteOnly(context, [file]);
showShortToast(context, AppLocalizations.of(context).movedToTrash);
- if (onFileRemoved != null) {
+ // Remove from viewer if:
+ // 1. File is remote-only (no local copy), OR
+ // 2. File has both copies but we're not in a local-only context
+ if (onFileRemoved != null && (isRemoteOnly || !isLocalOnlyContext)) {
onFileRemoved(file);
}
},
diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
index 0af6515d61..2b595d1630 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
@@ -41,12 +41,14 @@ class DetailPageConfiguration {
final int selectedIndex;
final String tagPrefix;
final DetailPageMode mode;
+ final bool isLocalOnlyContext;
DetailPageConfiguration(
this.files,
this.selectedIndex,
this.tagPrefix, {
this.mode = DetailPageMode.full,
+ this.isLocalOnlyContext = false,
});
DetailPageConfiguration copyWith({
@@ -54,11 +56,13 @@ class DetailPageConfiguration {
GalleryLoader? asyncLoader,
int? selectedIndex,
String? tagPrefix,
+ bool? isLocalOnlyContext,
}) {
return DetailPageConfiguration(
files ?? this.files,
selectedIndex ?? this.selectedIndex,
tagPrefix ?? this.tagPrefix,
+ isLocalOnlyContext: isLocalOnlyContext ?? this.isLocalOnlyContext,
);
}
}
@@ -196,6 +200,7 @@ class _BodyState extends State<_Body> {
enableFullScreenNotifier:
InheritedDetailPageState.of(context)
.enableFullScreenNotifier,
+ isLocalOnlyContext: widget.config.isLocalOnlyContext,
);
},
valueListenable: _selectedIndexNotifier,
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
index 342dc0b32d..f85e1aaf91 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
@@ -26,6 +26,7 @@ class FileBottomBar extends StatefulWidget {
final bool showOnlyInfoButton;
final int? userID;
final ValueNotifier<bool> enableFullScreenNotifier;
+ final bool isLocalOnlyContext;
const FileBottomBar(
this.file,
@@ -34,6 +35,7 @@ class FileBottomBar extends StatefulWidget {
required this.onFileRemoved,
required this.enableFullScreenNotifier,
this.userID,
+ this.isLocalOnlyContext = false,
super.key,
});
@@ -220,6 +222,7 @@ class FileBottomBarState extends State<FileBottomBar> {
context,
file,
onFileRemoved: widget.onFileRemoved,
+ isLocalOnlyContext: widget.isLocalOnlyContext,
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
index 97f8ace2b8..bc952aad08 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
@@ -212,11 +212,15 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {
void _routeToDetailPage(EnteFile file, BuildContext context) {
final galleryFiles = GalleryFilesState.of(context).galleryFiles;
+ // Device folders are local-only contexts where files should remain visible
+ // even after deleting from Ente (remote)
+ final isLocalOnlyContext = widget.tag.startsWith("device_folder:");
final page = DetailPage(
DetailPageConfiguration(
galleryFiles,
galleryFiles.indexOf(file),
widget.tag,
+ isLocalOnlyContext: isLocalOnlyContext,
),
);
routeToPage(context, page, forceCustomPageRoute: true);