π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] improve Uncategorized cleanup feedback
r4khul81f48c8abca8
diff --git a/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dartindex 69caf47f56..3a28d7b52d 100644--- a/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart+++ b/mobile/apps/photos/lib/ui/actions/collection/collection_sharing_actions.dart@@ -518,7 +518,8 @@ class CollectionActions {await collectionsService.trashEmptyCollection(collection);}- Future<void> removeFromUncatIfPresentInOtherAlbum(+ Future<({int uncategorizedFilesCount, int removedFilesCount})>+ removeFromUncatIfPresentInOtherAlbum(Collection collection,BuildContext bContext,) async {@@ -526,15 +527,21 @@ class CollectionActions {final List<EnteFile> files = await FilesDB.instance.getAllFilesCollection(collection.id,);- if (!bContext.mounted) return;- await moveFilesFromCurrentCollection(bContext, collection, files);- } catch (e) {- logger.severe("Failed to remove files from uncategorized", e);- if (!bContext.mounted) return;- await showErrorDialogForException(- context: bContext,- exception: e as Exception,+ if (!bContext.mounted) {+ return (uncategorizedFilesCount: files.length, removedFilesCount: 0);+ }+ final removedFilesCount = await moveFilesFromCurrentCollection(+ bContext,+ collection,+ files,);+ return (+ uncategorizedFilesCount: files.length,+ removedFilesCount: removedFilesCount,+ );+ } catch (e, s) {+ logger.severe("Failed to remove files from uncategorized", e, s);+ rethrow;}}@@ -556,12 +563,13 @@ class CollectionActions {// Moving an owned file must call the move API even if it is already in// another owned collection, because move also removes it from this one.// Files owned by someone else can only be removed from this collection.- Future<void> moveFilesFromCurrentCollection(+ Future<int> moveFilesFromCurrentCollection(BuildContext? context,Collection collection,Iterable<EnteFile> files, {bool isHidden = false,}) async {+ var movedFilesCount = 0;final int currentUserID = Configuration.instance.getUserID()!;final isCollectionOwner = collection.owner.id == currentUserID;final bool canRemoveAllParticipants = collectionsService@@ -583,26 +591,27 @@ class CollectionActions {filesToRemove,);}- return;+ return filesToRemove.length;}if (isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) {await collectionsService.removeFromCollection(collection.id,split.ownedByOtherUsers,);+ movedFilesCount += split.ownedByOtherUsers.length;} else if (!isCollectionOwner && split.ownedByCurrentUser.isNotEmpty) {await collectionsService.removeFromCollection(collection.id,split.ownedByCurrentUser,);- return;+ return split.ownedByCurrentUser.length;}if (!isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) {if (context != null && context.mounted) {showShortToast(context, context.strings.canOnlyRemoveFilesOwnedByYou);}- return;+ return movedFilesCount;}final Map<int, EnteFile> pendingAssignMap = {};@@ -693,13 +702,16 @@ class CollectionActions {'skipping moving ${entry.value.length} files to uncategorized collection',);} else {+ final movedFilesInCollection = entry.value.length;await collectionsService.move(entry.value,toCollectionID: entry.key,fromCollectionID: collection.id,);+ movedFilesCount += movedFilesInCollection;}}+ return movedFilesCount;}bool _isAutoMoveCandidate(int fromCollectionID, toCollectionID, int userID) {diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dartindex 74b34eb6b7..00a8668952 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart@@ -1085,19 +1085,36 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {}Future<void> onCleanUncategorizedClick(BuildContext buildContext) async {+ var cleanupResult = (uncategorizedFilesCount: 0, removedFilesCount: 0);final actionResult = await showChoiceActionSheet(context,isCritical: true,title: context.strings.cleanUncategorized,firstButtonLabel: context.strings.confirm,body: context.strings.cleanUncategorizedDescription,+ firstButtonOnTap: () async {+ cleanupResult = await collectionActions+ .removeFromUncatIfPresentInOtherAlbum(widget.collection!, context);+ },);if (actionResult?.action != null && mounted) {if (actionResult!.action == ButtonAction.first) {if (!buildContext.mounted) return;- await collectionActions.removeFromUncatIfPresentInOtherAlbum(- widget.collection!,+ showShortToast(buildContext,+ cleanupResult.removedFilesCount > 0+ ? buildContext.strings.cleanedUncategorizedItems(+ count: cleanupResult.removedFilesCount,+ )+ : cleanupResult.uncategorizedFilesCount == 0+ ? buildContext.strings.uncategorizedIsClean+ : buildContext.strings.nothingToCleanUpInUncategorized,+ );+ } else if (actionResult.action == ButtonAction.error) {+ if (!buildContext.mounted) return;+ await showGenericErrorDialog(+ context: buildContext,+ error: actionResult.exception,);}}diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex b0ad4aabb0..59e4617566 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -654,6 +654,14 @@},"cleanUncategorized": "Clean Uncategorized","cleanUncategorizedDescription": "Remove all files from Uncategorized that are present in other albums",+ "cleanedUncategorizedItems": "{count, plural, one{Cleaned {count} item.} other{Cleaned {count} items.}}",+ "@cleanedUncategorizedItems": {+ "placeholders": {+ "count": {+ "type": "num"+ }+ }+ },"cleanupComplete": "Cleanup complete","cleanupHiddenFiles": "Clean up hidden files","cleanupHiddenFilesDescription": "Some files in hidden albums still exist in non-hidden albums making them visible outside of the hidden section. Cleaning up will remove them from non-hidden albums.",@@ -2898,6 +2906,7 @@}},"nothingToSeeHere": "Nothing to see here",+ "nothingToCleanUpInUncategorized": "Nothing to clean up. These files are not in your other albums.","nothingToTidyUpHere": "Nothing to tidy up here","notifications": "Notifications","notifyMe": "Notify me",@@ -4615,6 +4624,7 @@"unarchiving": "Unarchiving...","unavailableReferralCode": "This code is already taken","uncategorized": "Uncategorized",+ "uncategorizedIsClean": "Uncategorized is clean.","uncategorizedItemsWillShowUpHere": "Uncategorized items will show up here","undo": "Undo","unhide": "Unhide",