π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Allow suggesting delete
Neeraj Guptafcda2a1cfe71
diff --git a/mobile/apps/photos/lib/models/gallery_type.dart b/mobile/apps/photos/lib/models/gallery_type.dartindex 2677373e53..081388e958 100644--- a/mobile/apps/photos/lib/models/gallery_type.dart+++ b/mobile/apps/photos/lib/models/gallery_type.dart@@ -11,6 +11,7 @@ enum GalleryType {hiddenOwnedCollection,favorite,trash,+ deleteSuggestions,localFolder,// indicator for gallery view of collections shared with the usersharedCollection,@@ -46,6 +47,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.trash:case GalleryType.cluster:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -71,6 +73,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.cluster:case GalleryType.sharedPublicCollection:case GalleryType.magic:+ case GalleryType.deleteSuggestions:return false;}}@@ -97,6 +100,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.hiddenOwnedCollection:case GalleryType.sharedCollection:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -121,6 +125,7 @@ extension GalleyTypeExtension on GalleryType {return true;case GalleryType.trash:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -145,6 +150,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.sharedCollection:case GalleryType.quickLink:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -169,6 +175,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.locationTag:case GalleryType.sharedPublicCollection:case GalleryType.magic:+ case GalleryType.deleteSuggestions:return false;}}@@ -194,6 +201,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.sharedCollection:case GalleryType.cluster:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -223,6 +231,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.favorite:case GalleryType.sharedCollection:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -253,6 +262,7 @@ extension GalleyTypeExtension on GalleryType {case GalleryType.trash:case GalleryType.sharedCollection:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;}}@@ -386,6 +396,7 @@ extension GalleryAppBarExtn on GalleryType {case GalleryType.searchResults:case GalleryType.magic:case GalleryType.sharedPublicCollection:+ case GalleryType.deleteSuggestions:return false;case GalleryType.uncategorized:case GalleryType.cluster:diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dartindex 486f0ef2b6..1a3c8c0cf2 100644--- a/mobile/apps/photos/lib/services/collections_service.dart+++ b/mobile/apps/photos/lib/services/collections_service.dart@@ -1354,6 +1354,50 @@ class CollectionsService {}}+ Future<List<int>> fetchDeleteSuggestionFileIDs() async {+ try {+ final response =+ await _enteDio.get("/collection-actions/delete-suggestions/");+ final List<dynamic> rawActions =+ (response.data["actions"] as List<dynamic>?) ?? const [];+ final actions = rawActions+ .map(+ (dynamic action) => CollectionAction.fromJson(+ Map<String, dynamic>.from(action as Map<dynamic, dynamic>),+ ),+ )+ .toList(growable: false);+ final Set<int> uniqueFileIDs = <int>{};+ for (final action in actions) {+ if (action.fileID != null) {+ uniqueFileIDs.add(action.fileID!);+ }+ }+ _logger.info(+ "Fetched ${uniqueFileIDs.length} unique delete suggestion file IDs",+ );+ return uniqueFileIDs.toList();+ } catch (e, s) {+ _logger.warning("Failed to fetch delete suggestion actions", e, s);+ rethrow;+ }+ }++ Future<void> rejectDeleteSuggestions(List<int> fileIDs) async {+ if (fileIDs.isEmpty) {+ return;+ }+ try {+ await _enteDio.post(+ "/collection-actions/reject-delete-suggestions/",+ data: {"fileIDs": fileIDs},+ );+ } catch (e, s) {+ _logger.warning("Failed to reject delete suggestions", e, s);+ rethrow;+ }+ }+Future<Collection> getCollectionFromPublicLink(BuildContext context,Uri uri,@@ -2176,6 +2220,39 @@ class CollectionsService {RemoteSyncService.instance.sync(silently: true).ignore();}+ Future<void> suggestDeleteFromCollection(+ int collectionID,+ List<EnteFile> files,+ ) async {+ final List<int> fileIDs =+ files.map((file) => file.uploadedFileID).whereType<int>().toList();+ if (fileIDs.isEmpty) {+ return;+ }+ final params = <String, dynamic>{+ "collectionID": collectionID,+ "fileIDs": fileIDs,+ };+ final resp = await _enteDio.post(+ "/collections/suggest-delete",+ data: params,+ );+ if (resp.statusCode != 200) {+ throw Exception("Failed to send delete suggestion");+ }++ await _filesDB.removeFromCollection(collectionID, fileIDs);+ Bus.instance.fire(+ CollectionUpdatedEvent(+ collectionID,+ files,+ "suggestDelete",+ ),+ );+ Bus.instance.fire(LocalPhotosUpdatedEvent(files, source: "suggestDelete"));+ RemoteSyncService.instance.sync(silently: true).ignore();+ }+Future<Collection> createAndCacheCollection(CreateRequest createRequest,) async {diff --git a/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart b/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dartindex ce2c516a32..d0271b9eaf 100644--- a/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart+++ b/mobile/apps/photos/lib/ui/settings/backup/free_space_options.dart@@ -24,6 +24,7 @@ import "package:photos/ui/tools/debug/app_storage_viewer.dart";import "package:photos/ui/tools/deduplicate_page.dart";import "package:photos/ui/tools/free_space_page.dart";import "package:photos/ui/tools/similar_images_page.dart";+import "package:photos/ui/viewer/gallery/delete_suggestions_page.dart";import "package:photos/ui/viewer/gallery/large_files_page.dart";import "package:photos/utils/dialog_util.dart";import 'package:photos/utils/navigation_util.dart';@@ -261,6 +262,39 @@ class _FreeUpSpaceOptionsScreenState extends State<FreeUpSpaceOptionsScreen> {const SizedBox(height: 24,),+ if (flagService.internalUser)+ MenuItemWidget(+ captionedTextWidget:+ const CaptionedTextWidget(+ title: "(i) Review delete suggestions",+ ),+ menuItemColor: colorScheme.fillFaint,+ trailingWidget: Icon(+ Icons.chevron_right_outlined,+ color: colorScheme.strokeBase,+ ),+ singleBorderRadius: 8,+ alignCaptionedTextToLeft: true,+ showOnlyLoadingState: true,+ onTap: () async {+ await routeToPage(+ context,+ DeleteSuggestionsPage(),+ );+ },+ ),+ if (flagService.internalUser)+ const Align(+ alignment: Alignment.centerLeft,+ child: MenuSectionDescriptionWidget(+ content:+ "See files that others have suggested you can delete.",+ ),+ ),+ if (flagService.internalUser)+ const SizedBox(+ height: 24,+ ),MenuItemWidget(captionedTextWidget: CaptionedTextWidget(title: AppLocalizations.of(context)diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dartindex 19ecd30248..c2932097e6 100644--- a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart@@ -7,6 +7,7 @@ import "package:logging/logging.dart";import "package:modal_bottom_sheet/modal_bottom_sheet.dart";import 'package:photos/core/configuration.dart';import "package:photos/core/event_bus.dart";+import "package:photos/events/files_updated_event.dart";import "package:photos/events/guest_view_event.dart";import "package:photos/events/people_changed_event.dart";import "package:photos/generated/l10n.dart";@@ -77,6 +78,11 @@ class _FileSelectionActionsWidgetStatelate FilesSplit split;late CollectionActions collectionActions;late bool isCollectionOwner;+ static const String _suggestDeleteLabel = "(i) Suggest delete";+ static const String _suggestDeleteDialogTitle = "(i) Suggest deletion";+ static const String _suggestDeleteDialogBody =+ "(i) This sends the owner a suggestion to remove these files. They will not be deleted automatically; the owner must manually review and approve the suggestion before anything is removed.";+ static const String _suggestDeleteSentMessage = "(i) Delete suggestion sent.";// _cachedCollectionForSharedLink is primarily used to avoid creating duplicate// links if user keeps on creating Create link button after selecting// few files. This link is reset on any selection changed;@@ -148,306 +154,342 @@ class _FileSelectionActionsWidgetState);final showDownloadOption =widget.selectedFiles.files.any((element) => element.localID == null);+ final bool isCollectionOwnerOrAdmin = widget.collection != null &&+ (widget.collection!.isOwner(currentUserID) ||+ widget.collection!.isAdmin(currentUserID));+ final bool canSuggestDeleteAction = flagService.enableDeleteSuggestion &&+ (widget.type == GalleryType.sharedCollection ||+ widget.type == GalleryType.ownedCollection) &&+ isCollectionOwnerOrAdmin &&+ split.ownedByOtherUsers.isNotEmpty;//To animate adding and removing of [SelectedActionButton], add all items//and set [shouldShow] to false for items that should not be shown and true//for items that should be shown.final List<SelectionActionButton> items = [];-- if (widget.type.showCreateLink()) {- if (_cachedCollectionForSharedLink != null && anyUploadedFiles) {+ if (widget.type == GalleryType.deleteSuggestions) {+ items.add(+ SelectionActionButton(+ icon: Icons.delete_outline,+ labelText: AppLocalizations.of(context).delete,+ onTap: split.ownedByCurrentUser.isNotEmpty ? _onDeleteClick : null,+ ),+ );+ items.add(+ SelectionActionButton(+ icon: Icons.clear,+ labelText: "Reject suggestions",+ onTap: widget.selectedFiles.files.isNotEmpty+ ? _rejectDeleteSuggestions+ : null,+ ),+ );+ } else {+ if (widget.type.showCreateLink()) {+ if (_cachedCollectionForSharedLink != null && anyUploadedFiles) {+ items.add(+ SelectionActionButton(+ icon: Icons.copy_outlined,+ labelText: AppLocalizations.of(context).copyLink,+ onTap: anyUploadedFiles ? _sendLink : null,+ ),+ );+ } else {+ items.add(+ SelectionActionButton(+ icon: Icons.navigation_rounded,+ labelText: AppLocalizations.of(context).sendLink,+ onTap: anyUploadedFiles ? _onSendLinkTapped : null,+ shouldShow: ownedFilesCount > 0,+ key: sendLinkButtonKey,+ ),+ );+ }+ }+ if (widget.type == GalleryType.peopleTag && widget.person != null) {items.add(SelectionActionButton(- icon: Icons.copy_outlined,- labelText: AppLocalizations.of(context).copyLink,- onTap: anyUploadedFiles ? _sendLink : null,+ icon: Icons.remove_circle_outline,+ labelText: AppLocalizations.of(context)+ .notPersonLabel(name: widget.person!.data.name),+ onTap: _onNotpersonClicked,),);- } else {+ if (ownedFilesCount == 1) {+ items.add(+ SelectionActionButton(+ icon: Icons.image_outlined,+ labelText: AppLocalizations.of(context).useAsCover,+ onTap: anyUploadedFiles ? _setPersonCover : null,+ ),+ );+ }+ }++ if (widget.type == GalleryType.cluster && widget.clusterID != null) {items.add(SelectionActionButton(- icon: Icons.navigation_rounded,- labelText: AppLocalizations.of(context).sendLink,- onTap: anyUploadedFiles ? _onSendLinkTapped : null,- shouldShow: ownedFilesCount > 0,- key: sendLinkButtonKey,+ labelText: AppLocalizations.of(context).notThisPerson,+ icon: Icons.remove_circle_outline,+ onTap: _onRemoveFromClusterClicked,),);}- }- if (widget.type == GalleryType.peopleTag && widget.person != null) {- items.add(- SelectionActionButton(- icon: Icons.remove_circle_outline,- labelText: AppLocalizations.of(context)- .notPersonLabel(name: widget.person!.data.name),- onTap: _onNotpersonClicked,- ),- );- if (ownedFilesCount == 1) {++ final showUploadIcon = widget.type == GalleryType.localFolder &&+ split.ownedByCurrentUser.isEmpty;+ if (widget.type.showAddToAlbum()) {+ if (showUploadIcon) {+ items.add(+ SelectionActionButton(+ icon: Icons.cloud_upload_outlined,+ labelText: AppLocalizations.of(context).addToEnte,+ onTap: _addToAlbum,+ ),+ );+ } else {+ items.add(+ SelectionActionButton(+ icon: Icons.add_outlined,+ labelText: AppLocalizations.of(context).addToAlbum,+ onTap: _addToAlbum,+ ),+ );+ }+ }++ if (widget.type.showAddtoHiddenAlbum()) {items.add(SelectionActionButton(- icon: Icons.image_outlined,- labelText: AppLocalizations.of(context).useAsCover,- onTap: anyUploadedFiles ? _setPersonCover : null,+ icon: Icons.add_outlined,+ labelText: AppLocalizations.of(context).addToAlbum,+ onTap: _addToHiddenAlbum,),);}- }-- if (widget.type == GalleryType.cluster && widget.clusterID != null) {- items.add(- SelectionActionButton(- labelText: AppLocalizations.of(context).notThisPerson,- icon: Icons.remove_circle_outline,- onTap: _onRemoveFromClusterClicked,- ),- );- }- final showUploadIcon = widget.type == GalleryType.localFolder &&- split.ownedByCurrentUser.isEmpty;- if (widget.type.showAddToAlbum()) {- if (showUploadIcon) {+ if (widget.type.showMoveToAlbum()) {items.add(SelectionActionButton(- icon: Icons.cloud_upload_outlined,- labelText: AppLocalizations.of(context).addToEnte,- onTap: _addToAlbum,+ icon: Icons.arrow_forward_outlined,+ labelText: AppLocalizations.of(context).moveToAlbum,+ onTap: anyUploadedFiles ? _moveFiles : null,+ shouldShow: ownedFilesCount > 0,),);- } else {+ }++ if (widget.type.showMovetoHiddenAlbum()) {items.add(SelectionActionButton(- icon: Icons.add_outlined,- labelText: AppLocalizations.of(context).addToAlbum,- onTap: _addToAlbum,+ icon: Icons.arrow_forward_outlined,+ labelText: AppLocalizations.of(context).moveToAlbum,+ onTap: _moveFilesToHiddenAlbum,),);}- }- if (widget.type.showAddtoHiddenAlbum()) {- items.add(- SelectionActionButton(- icon: Icons.add_outlined,- labelText: AppLocalizations.of(context).addToAlbum,- onTap: _addToHiddenAlbum,- ),- );- }-- if (widget.type.showMoveToAlbum()) {- items.add(- SelectionActionButton(- icon: Icons.arrow_forward_outlined,- labelText: AppLocalizations.of(context).moveToAlbum,- onTap: anyUploadedFiles ? _moveFiles : null,- shouldShow: ownedFilesCount > 0,- ),- );- }-- if (widget.type.showMovetoHiddenAlbum()) {- items.add(- SelectionActionButton(- icon: Icons.arrow_forward_outlined,- labelText: AppLocalizations.of(context).moveToAlbum,- onTap: _moveFilesToHiddenAlbum,- ),- );- }+ if (widget.type.showDeleteOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.delete_outline,+ labelText: AppLocalizations.of(context).delete,+ onTap: anyOwnedFiles ? _onDeleteClick : null,+ shouldShow: allOwnedFiles,+ ),+ );+ }- if (widget.type.showDeleteOption()) {- items.add(- SelectionActionButton(- icon: Icons.delete_outline,- labelText: AppLocalizations.of(context).delete,- onTap: anyOwnedFiles ? _onDeleteClick : null,- shouldShow: allOwnedFiles,- ),- );- }+ if (widget.type.showRemoveFromAlbum()) {+ items.add(+ SelectionActionButton(+ icon: Icons.remove_outlined,+ labelText: AppLocalizations.of(context).removeFromAlbum,+ onTap: removeCount > 0 ? _removeFilesFromAlbum : null,+ shouldShow: removeCount > 0,+ ),+ );+ }- if (widget.type.showRemoveFromAlbum()) {- items.add(- SelectionActionButton(- icon: Icons.remove_outlined,- labelText: AppLocalizations.of(context).removeFromAlbum,- onTap: removeCount > 0 ? _removeFilesFromAlbum : null,- shouldShow: removeCount > 0,- ),- );- }+ if (canSuggestDeleteAction) {+ items.add(+ SelectionActionButton(+ icon: Icons.flag_outlined,+ labelText: _suggestDeleteLabel,+ onTap: _onSuggestDelete,+ ),+ );+ }- if (widget.type.showRemoveFromHiddenAlbum()) {- items.add(- SelectionActionButton(- icon: Icons.remove_outlined,- labelText: AppLocalizations.of(context).removeFromAlbum,- onTap: _removeFilesFromHiddenAlbum,- ),- );- }+ if (widget.type.showRemoveFromHiddenAlbum()) {+ items.add(+ SelectionActionButton(+ icon: Icons.remove_outlined,+ labelText: AppLocalizations.of(context).removeFromAlbum,+ onTap: _removeFilesFromHiddenAlbum,+ ),+ );+ }- if (widget.type.showFavoriteOption()) {- items.add(- SelectionActionButton(- icon: Icons.favorite_border_rounded,- labelText: AppLocalizations.of(context).favorite,- onTap: anyUploadedFiles ? _onFavoriteClick : null,- shouldShow: ownedFilesCount > 0,- ),- );- } else if (widget.type.showUnFavoriteOption()) {- items.add(- SelectionActionButton(- icon: Icons.favorite,- labelText: AppLocalizations.of(context).removeFromFavorite,- onTap: _onUnFavoriteClick,- shouldShow: ownedFilesCount > 0,- ),- );- }- items.add(- SelectionActionButton(- svgAssetPath: "assets/icons/guest_view_icon.svg",- labelText: AppLocalizations.of(context).guestView,- onTap: _onGuestViewClick,- ),- );- if (widget.type != GalleryType.sharedPublicCollection) {- items.add(- SelectionActionButton(- icon: Icons.grid_view_outlined,- labelText: AppLocalizations.of(context).createCollage,- onTap: _onCreateCollageClicked,- shouldShow: showCollageOption,- ),- );- }- if (flagService.internalUser &&- widget.type != GalleryType.sharedPublicCollection) {+ if (widget.type.showFavoriteOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.favorite_border_rounded,+ labelText: AppLocalizations.of(context).favorite,+ onTap: anyUploadedFiles ? _onFavoriteClick : null,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ } else if (widget.type.showUnFavoriteOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.favorite,+ labelText: AppLocalizations.of(context).removeFromFavorite,+ onTap: _onUnFavoriteClick,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ }items.add(SelectionActionButton(- icon: Icons.movie_creation_sharp,- labelText: "(i) Video Memory",- onTap: _onCreateVideoMemoryClicked,+ svgAssetPath: "assets/icons/guest_view_icon.svg",+ labelText: AppLocalizations.of(context).guestView,+ onTap: _onGuestViewClick,),);- }+ if (widget.type != GalleryType.sharedPublicCollection) {+ items.add(+ SelectionActionButton(+ icon: Icons.grid_view_outlined,+ labelText: AppLocalizations.of(context).createCollage,+ onTap: _onCreateCollageClicked,+ shouldShow: showCollageOption,+ ),+ );+ }+ if (flagService.internalUser &&+ widget.type != GalleryType.sharedPublicCollection) {+ items.add(+ SelectionActionButton(+ icon: Icons.movie_creation_sharp,+ labelText: "(i) Video Memory",+ onTap: _onCreateVideoMemoryClicked,+ ),+ );+ }- if (widget.type.showHideOption()) {- items.add(- SelectionActionButton(- icon: Icons.visibility_off_outlined,- labelText: AppLocalizations.of(context).hide,- onTap: anyUploadedFiles ? _onHideClick : null,- shouldShow: ownedFilesCount > 0,- ),- );- } else if (widget.type.showUnHideOption()) {- items.add(- SelectionActionButton(- icon: Icons.visibility_outlined,- labelText: AppLocalizations.of(context).unhide,- onTap: _onUnhideClick,- shouldShow: ownedFilesCount > 0,- ),- );- }- if (widget.type.showArchiveOption()) {- items.add(- SelectionActionButton(- icon: Icons.archive_outlined,- labelText: AppLocalizations.of(context).archive,- onTap: anyUploadedFiles ? _onArchiveClick : null,- shouldShow: ownedFilesCount > 0,- ),- );- } else if (widget.type.showUnArchiveOption()) {- items.add(- SelectionActionButton(- icon: Icons.unarchive,- labelText: AppLocalizations.of(context).unarchive,- onTap: _onUnArchiveClick,- shouldShow: ownedFilesCount > 0,- ),- );- }+ if (widget.type.showHideOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.visibility_off_outlined,+ labelText: AppLocalizations.of(context).hide,+ onTap: anyUploadedFiles ? _onHideClick : null,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ } else if (widget.type.showUnHideOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.visibility_outlined,+ labelText: AppLocalizations.of(context).unhide,+ onTap: _onUnhideClick,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ }+ if (widget.type.showArchiveOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.archive_outlined,+ labelText: AppLocalizations.of(context).archive,+ onTap: anyUploadedFiles ? _onArchiveClick : null,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ } else if (widget.type.showUnArchiveOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.unarchive,+ labelText: AppLocalizations.of(context).unarchive,+ onTap: _onUnArchiveClick,+ shouldShow: ownedFilesCount > 0,+ ),+ );+ }- if (widget.type.showRestoreOption()) {- items.add(- SelectionActionButton(- icon: Icons.restore_outlined,- labelText: AppLocalizations.of(context).restore,- onTap: _restore,- ),- );- }+ if (widget.type.showRestoreOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.restore_outlined,+ labelText: AppLocalizations.of(context).restore,+ onTap: _restore,+ ),+ );+ }- if (widget.type.showPermanentlyDeleteOption()) {- items.add(- SelectionActionButton(- icon: Icons.delete_forever_outlined,- labelText: AppLocalizations.of(context).permanentlyDelete,- onTap: _permanentlyDelete,- ),- );- }+ if (widget.type.showPermanentlyDeleteOption()) {+ items.add(+ SelectionActionButton(+ icon: Icons.delete_forever_outlined,+ labelText: AppLocalizations.of(context).permanentlyDelete,+ onTap: _permanentlyDelete,+ ),+ );+ }- if (widget.type.showBulkEditTime()) {- items.add(- SelectionActionButton(- shouldShow: widget.selectedFiles.files.every(- (element) => (element.ownerID == currentUserID),+ if (widget.type.showBulkEditTime()) {+ items.add(+ SelectionActionButton(+ shouldShow: widget.selectedFiles.files.every(+ (element) => (element.ownerID == currentUserID),+ ),+ labelText: AppLocalizations.of(context).editTime,+ icon: Icons.edit_calendar_outlined,+ onTap: () async {+ final newDate = await showEditDateSheet(+ context,+ widget.selectedFiles.files,+ );+ if (newDate != null) {+ widget.selectedFiles.clearAll();+ }+ },),- labelText: AppLocalizations.of(context).editTime,- icon: Icons.edit_calendar_outlined,- onTap: () async {- final newDate = await showEditDateSheet(- context,- widget.selectedFiles.files,- );- if (newDate != null) {- widget.selectedFiles.clearAll();- }- },- ),- );- }+ );+ }- if (widget.type.showEditLocation()) {- items.add(- SelectionActionButton(- shouldShow: widget.selectedFiles.files.any(- (element) => (element.ownerID == currentUserID),+ if (widget.type.showEditLocation()) {+ items.add(+ SelectionActionButton(+ shouldShow: widget.selectedFiles.files.any(+ (element) => (element.ownerID == currentUserID),+ ),+ labelText: AppLocalizations.of(context).editLocation,+ icon: Icons.edit_location_alt_outlined,+ onTap: _editLocation,),- labelText: AppLocalizations.of(context).editLocation,- icon: Icons.edit_location_alt_outlined,- onTap: _editLocation,- ),- );- }+ );+ }- if (showDownloadOption) {- items.add(- SelectionActionButton(- labelText: AppLocalizations.of(context).download,- icon: Icons.cloud_download_outlined,- onTap: () => _download(widget.selectedFiles.files.toList()),- ),- );- }- if (widget.type != GalleryType.sharedPublicCollection) {- items.add(- SelectionActionButton(- labelText: AppLocalizations.of(context).share,- icon: Icons.adaptive.share_outlined,- key: shareButtonKey,- onTap: _shareSelectedFiles,- ),- );+ if (showDownloadOption) {+ items.add(+ SelectionActionButton(+ labelText: AppLocalizations.of(context).download,+ icon: Icons.cloud_download_outlined,+ onTap: () => _download(widget.selectedFiles.files.toList()),+ ),+ );+ }+ if (widget.type != GalleryType.sharedPublicCollection) {+ items.add(+ SelectionActionButton(+ labelText: AppLocalizations.of(context).share,+ icon: Icons.adaptive.share_outlined,+ key: shareButtonKey,+ onTap: _shareSelectedFiles,+ ),+ );+ }}if (items.isNotEmpty) {@@ -571,6 +613,91 @@ class _FileSelectionActionsWidgetStatereturn showDeleteSheet(context, widget.selectedFiles, split);}+ Future<void> _rejectDeleteSuggestions() async {+ final fileIDs = widget.selectedFiles.files+ .map((file) => file.uploadedFileID)+ .whereType<int>()+ .toSet()+ .toList();+ if (fileIDs.isEmpty) {+ return;+ }+ try {+ await CollectionsService.instance.rejectDeleteSuggestions(fileIDs);+ widget.selectedFiles.clearAll();+ Bus.instance.fire(+ FilesUpdatedEvent(+ const [],+ source: "reject-delete-suggestions",+ ),+ );+ } catch (e, s) {+ _logger.warning("Failed to reject delete suggestions", e, s);+ await showGenericErrorDialog(+ context: context,+ error: e,+ );+ }+ }++ Future<void> _onSuggestDelete() async {+ if (widget.collection == null) {+ return;+ }+ final List<EnteFile> filesToSuggest = split.ownedByOtherUsers+ .where((file) => file.uploadedFileID != null)+ .toList();+ if (filesToSuggest.isEmpty) {+ return;+ }+ final actionResult = await showActionSheet(+ context: context,+ title: _suggestDeleteDialogTitle,+ body: _suggestDeleteDialogBody,+ actionSheetType: ActionSheetType.defaultActionSheet,+ buttons: [+ ButtonWidget(+ labelText: _suggestDeleteLabel,+ buttonType: ButtonType.neutral,+ buttonSize: ButtonSize.large,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.first,+ isInAlert: true,+ onTap: () async {+ await CollectionsService.instance.suggestDeleteFromCollection(+ widget.collection!.id,+ filesToSuggest,+ );+ showShortToast(+ context,+ _suggestDeleteSentMessage,+ );+ },+ ),+ ButtonWidget(+ labelText: AppLocalizations.of(context).cancel,+ buttonType: ButtonType.secondary,+ buttonSize: ButtonSize.large,+ buttonAction: ButtonAction.second,+ shouldStickToDarkTheme: true,+ isInAlert: true,+ ),+ ],+ );+ if (actionResult?.action == ButtonAction.error) {+ await showGenericErrorDialog(+ context: context,+ error: actionResult?.exception ??+ Exception("Failed to send delete suggestion"),+ );+ } else if (actionResult?.action == ButtonAction.first) {+ widget.selectedFiles.clearAll();+ if (mounted) {+ setState(() => {});+ }+ }+ }+Future<void> _removeFilesFromAlbum() async {if (split.pendingUploads.isNotEmpty) {widget.selectedFilesdiff --git a/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dartnew file mode 100644index 0000000000..cf5cd4b77e--- /dev/null+++ b/mobile/apps/photos/lib/ui/viewer/gallery/delete_suggestions_page.dart@@ -0,0 +1,79 @@+import "package:flutter/material.dart";+import "package:photos/core/event_bus.dart";+import "package:photos/db/files_db.dart";+import "package:photos/events/files_updated_event.dart";+import "package:photos/models/file_load_result.dart";+import "package:photos/models/gallery_type.dart";+import "package:photos/models/selected_files.dart";+import "package:photos/services/collections_service.dart";+import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";+import "package:photos/ui/viewer/gallery/gallery.dart";+import "package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart";+import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";+import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";+import "package:photos/ui/viewer/gallery/state/selection_state.dart";++class DeleteSuggestionsPage extends StatelessWidget {+ final String tagPrefix;+ final GalleryType appBarType;+ final GalleryType overlayType;+ final _selectedFiles = SelectedFiles();++ DeleteSuggestionsPage({+ this.tagPrefix = "delete_suggestions_page",+ this.appBarType = GalleryType.deleteSuggestions,+ this.overlayType = GalleryType.deleteSuggestions,+ super.key,+ });++ @override+ Widget build(BuildContext context) {+ final gallery = Gallery(+ asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async {+ final fileIDs =+ await CollectionsService.instance.fetchDeleteSuggestionFileIDs();+ if (fileIDs.isEmpty) {+ return FileLoadResult([], false);+ }+ final files = await FilesDB.instance.getFilesFromIDs(+ fileIDs,+ dedupeByUploadId: true,+ );+ return FileLoadResult(files, false);+ },+ reloadEvent: Bus.instance.on<FilesUpdatedEvent>(),+ tagPrefix: tagPrefix,+ selectedFiles: _selectedFiles,+ galleryType: GalleryType.deleteSuggestions,+ enableFileGrouping: false,+ );++ return GalleryBoundariesProvider(+ child: GalleryFilesState(+ child: Scaffold(+ appBar: PreferredSize(+ preferredSize: const Size.fromHeight(50.0),+ child: GalleryAppBarWidget(+ appBarType,+ "Review delete suggestions",+ _selectedFiles,+ ),+ ),+ body: SelectionState(+ selectedFiles: _selectedFiles,+ child: Stack(+ alignment: Alignment.bottomCenter,+ children: [+ gallery,+ FileSelectionOverlayBar(+ overlayType,+ _selectedFiles,+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex d7c2a69bb8..2c383b39c8 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -160,6 +160,7 @@ class GalleryState extends State<Gallery> {List<EnteFile> _allFilesWithDummies = [];SwipeToSelectHelper? _swipeHelper;final _swipeActiveNotifier = ValueNotifier<bool>(false);+ InheritedSearchFilterData? _inheritedSearchFilterData;@overridevoid initState() {@@ -327,6 +328,12 @@ class GalleryState extends State<Gallery> {}}+ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ _inheritedSearchFilterData = InheritedSearchFilterData.maybeOf(context);+ }+void _updateGalleryGroups({bool callSetState = true}) {if (groupHeaderExtent == null) return;galleryGroups = GalleryGroups(@@ -528,8 +535,7 @@ class GalleryState extends State<Gallery> {return result;}final searchFilterDataProvider =- InheritedSearchFilterData.maybeOf(context)- ?.searchFilterDataProvider;+ _inheritedSearchFilterData?.searchFilterDataProvider;if (searchFilterDataProvider != null &&!searchFilterDataProvider.isSearchingNotifier.value) {unawaited(diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dartindex 1393b9802a..4f839f3dc1 100644--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart@@ -50,6 +50,7 @@ class FlagService {bool get enableAdminRole => internalUser;bool get surfacePublicLink => internalUser;+ bool get enableDeleteSuggestion => internalUser;bool get betaUser => flags.betaUser;