Skip to content

armgit / ente

Public Imported from GitHub
0

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

Replace tag-based check with GalleryType enum

Prateek Sunal24711496467f
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 bc952aad08..f2ac3188df 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
@@ -4,6 +4,7 @@ import "package:media_extension/media_extension.dart";
import "package:media_extension/media_extension_action_types.dart";
import "package:photos/core/constants.dart";
import 'package:photos/models/file/file.dart';
+import "package:photos/models/gallery_type.dart";
import "package:photos/models/selected_files.dart";
import "package:photos/services/app_lifecycle_service.dart";
import "package:photos/theme/ente_theme.dart";
@@ -212,9 +213,10 @@ 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:");
+ // Device folders (local-only contexts) should keep files visible
+ // even after deleting from Ente (remote) since they still exist locally
+ final galleryType = GalleryContextState.of(context)?.galleryType;
+ final isLocalOnlyContext = galleryType == GalleryType.localFolder;
final page = DetailPage(
DetailPageConfiguration(
galleryFiles,
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart
index e6ab0822c5..47da9fbb92 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/device_folder_page.dart
@@ -52,6 +52,7 @@ class DeviceFolderPage extends StatelessWidget {
EventType.hide,
},
tagPrefix: "device_folder:" + deviceCollection.name,
+ galleryType: GalleryType.localFolder,
selectedFiles: _selectedFiles,
header: Configuration.instance.hasConfiguredAccount()
? BackupHeaderWidget(deviceCollection)
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index bb537972ba..e48aad0a6e 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -560,6 +560,7 @@ class GalleryState extends State<Gallery> {
sortOrderAsc: _sortOrderAsc,
inSelectionMode: widget.inSelectionMode,
type: _groupType,
+ galleryType: widget.galleryType,
child: _allGalleryFiles.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_context_state.dart b/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_context_state.dart
index a3e7ae6048..ae324fd5d4 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_context_state.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/state/gallery_context_state.dart
@@ -1,4 +1,5 @@
import "package:flutter/material.dart";
+import "package:photos/models/gallery_type.dart";
import "package:photos/ui/viewer/gallery/component/group/type.dart";
class GalleryContextState extends InheritedWidget {
@@ -6,10 +7,12 @@ class GalleryContextState extends InheritedWidget {
final bool sortOrderAsc;
final bool inSelectionMode;
final GroupType type;
+ final GalleryType? galleryType;
const GalleryContextState({
this.inSelectionMode = false,
this.type = GroupType.day,
+ this.galleryType,
required this.sortOrderAsc,
required super.child,
super.key,
@@ -23,6 +26,7 @@ class GalleryContextState extends InheritedWidget {
bool updateShouldNotify(GalleryContextState oldWidget) {
return sortOrderAsc != oldWidget.sortOrderAsc ||
inSelectionMode != oldWidget.inSelectionMode ||
- type != oldWidget.type;
+ type != oldWidget.type ||
+ galleryType != oldWidget.galleryType;
}
}