π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
chore: update addFiles logic
Prateek Sunal03d21bc3ff25
diff --git a/mobile/apps/photos/lib/models/collection/smart_album_config.dart b/mobile/apps/photos/lib/models/collection/smart_album_config.dartindex da4e1c358e..05332ee58d 100644--- a/mobile/apps/photos/lib/models/collection/smart_album_config.dart+++ b/mobile/apps/photos/lib/models/collection/smart_album_config.dart@@ -43,16 +43,25 @@ class SmartAlbumConfig {);}- SmartAlbumConfig addFiles(String personId, int updatedAt, Set<int> fileId) {- if (!infoMap.containsKey(personId)) {- return this;- }-+ SmartAlbumConfig addFiles(+ Map<String, int> personUpdatedAt,+ Map<String, Set<int>> personMappedFiles,+ ) {final newInfoMap = Map<String, PersonInfo>.from(infoMap);- newInfoMap[personId] = (- updatedAt: updatedAt,- addedFiles: newInfoMap[personId]!.addedFiles.union(fileId),- );+ var isUpdated = false;++ personMappedFiles.forEach((personId, fileIds) {+ if (newInfoMap.containsKey(personId)) {+ isUpdated = true;+ newInfoMap[personId] = (+ updatedAt: personUpdatedAt[personId] ??+ DateTime.now().millisecondsSinceEpoch,+ addedFiles: {...?newInfoMap[personId]?.addedFiles, ...fileIds},+ );+ }+ });++ if (!isUpdated) return this;return SmartAlbumConfig(id: id,diff --git a/mobile/apps/photos/lib/services/smart_albums_service.dart b/mobile/apps/photos/lib/services/smart_albums_service.dartindex 065fbd8825..b41e720e4f 100644--- a/mobile/apps/photos/lib/services/smart_albums_service.dart+++ b/mobile/apps/photos/lib/services/smart_albums_service.dart@@ -113,7 +113,7 @@ class SmartAlbumsService {config.personIDs.toList(),);- Set<EnteFile> toBeSynced = {};+ Map<String, List<EnteFile>> toBeSynced = {};var newConfig = config;for (final personId in config.personIDs) {@@ -137,13 +137,7 @@ class SmartAlbumsService {e.ownerID != userId,);- toBeSynced = {...toBeSynced, ...fileIds};-- newConfig = newConfig.addFiles(- personId,- updatedAtMap[personId]!,- toBeSynced.map((e) => e.uploadedFileID!).toSet(),- );+ toBeSynced = {...toBeSynced, personId: fileIds};}syncingCollection = (collectionId, true);@@ -154,9 +148,16 @@ class SmartAlbumsService {if (toBeSynced.isNotEmpty) {try {await CollectionsService.instance.addOrCopyToCollection(- toCopy: false,collectionId,- toBeSynced.toList(),+ toBeSynced.entries.map((e) => e.value).expand((e) => e).toList(),+ toCopy: false,+ );+ newConfig = newConfig.addFiles(+ updatedAtMap,+ toBeSynced.map(+ (key, value) =>+ MapEntry(key, value.map((e) => e.uploadedFileID!).toSet()),+ ),);await saveConfig(newConfig);