π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Keep Important removals in owned collections (#14207)
aman-pilot7f6a898d171d
diff --git a/mobile/apps/locker/changes/important-owned-collections.md b/mobile/apps/locker/changes/important-owned-collections.mdnew file mode 100644index 0000000000..e7ec5780e7--- /dev/null+++ b/mobile/apps/locker/changes/important-owned-collections.md@@ -0,0 +1 @@+- Kept items in your own collections when removing them from Important.diff --git a/mobile/apps/locker/lib/services/collections/collections_api_client.dart b/mobile/apps/locker/lib/services/collections/collections_api_client.dartindex 27f0973f47..6b98715ad8 100644--- a/mobile/apps/locker/lib/services/collections/collections_api_client.dart+++ b/mobile/apps/locker/lib/services/collections/collections_api_client.dart@@ -243,6 +243,8 @@ class CollectionApiClient {return;}+ _validateMoveRequest(files, fromCollection, toCollection);+final params = <String, dynamic>{};params["fromCollectionID"] = fromCollection.id;params["toCollectionID"] = toCollection.id;@@ -297,6 +299,34 @@ class CollectionApiClient {}}+ void _validateMoveRequest(+ List<EnteFile> files,+ Collection fromCollection,+ Collection toCollection,+ ) {+ final userID = _config.getUserID();+ if (userID == null) {+ throw AssertionError("Must be signed in to move files");+ }+ if (!toCollection.isOwner(userID)) {+ throw AssertionError("Can't move to a collection you don't own");+ }+ if (!fromCollection.isOwner(userID)) {+ throw AssertionError("Can't move from a collection you don't own");+ }+ if (toCollection.isDeleted) {+ throw AssertionError("Can't move to a deleted collection");+ }+ if (fromCollection.isDeleted) {+ throw AssertionError("Can't move from a deleted collection");+ }+ for (final file in files) {+ if (file.ownerID != userID) {+ throw AssertionError("Can only move files owned by you");+ }+ }+ }+Future<void> trashCollection(Collection collection, {bool keepFiles = false,diff --git a/mobile/apps/locker/lib/services/favorites_service.dart b/mobile/apps/locker/lib/services/favorites_service.dartindex 93490ed686..eaae8540e4 100644--- a/mobile/apps/locker/lib/services/favorites_service.dart+++ b/mobile/apps/locker/lib/services/favorites_service.dart@@ -170,7 +170,7 @@ class FavoritesService {Collection? targetCollection;for (final col in currentCollections) {- if (col.id != favCollection.id) {+ if (_isAutoMoveCandidate(favCollection.id, col, currentUserID)) {targetCollection = col;break;}@@ -221,7 +221,7 @@ class FavoritesService {Collection? targetCollection;for (final col in currentCollections) {- if (col.id != favCollection.id) {+ if (_isAutoMoveCandidate(favCollection.id, col, _config.getUserID()!)) {targetCollection = col;break;}@@ -236,6 +236,20 @@ class FavoritesService {_updateFavoriteFilesCache([file], favFlag: false);}+ bool _isAutoMoveCandidate(+ int fromCollectionID,+ Collection toCollection,+ int userID,+ ) {+ if (fromCollectionID == toCollection.id) {+ return false;+ }+ if (toCollection.isDeleted || !toCollection.isOwner(userID)) {+ return false;+ }+ return true;+ }+Future<Collection?> getFavoritesCollection() async {final userID = _config.getUserID();if (userID == null) {