π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix manual tagging filtering bug
laurenspriem1e9bb4127b7d
diff --git a/mobile/apps/photos/lib/utils/hierarchical_search_util.dart b/mobile/apps/photos/lib/utils/hierarchical_search_util.dartindex ef5f1081fe..e73e5b7cd9 100644--- a/mobile/apps/photos/lib/utils/hierarchical_search_util.dart+++ b/mobile/apps/photos/lib/utils/hierarchical_search_util.dart@@ -30,6 +30,32 @@ import "package:photos/services/search_service.dart";import "package:photos/ui/viewer/gallery/state/search_filter_data_provider.dart";import "package:photos/utils/file_util.dart";+Future<Set<int>> _getFileIDsOfPersonIncludingManualAssignments(+ String personID,+) async {+ final fileIDs =+ (await MLDataDB.instance.getFileIDsOfPersonID(personID)).toSet();+ final person = await PersonService.instance.getPerson(personID);+ if (person != null) {+ fileIDs.addAll(person.data.manuallyAssigned);+ }+ return fileIDs;+}++Future<Set<int>> _getManualAssignmentFileIDsOfOtherPersons(+ Set<String> selectedPersonIDs,+) async {+ final fileIDs = <int>{};+ final persons = await PersonService.instance.getPersons();+ for (final person in persons) {+ if (selectedPersonIDs.contains(person.remoteID)) {+ continue;+ }+ fileIDs.addAll(person.data.manuallyAssigned);+ }+ return fileIDs;+}+Future<List<EnteFile>> getFilteredFiles(List<HierarchicalSearchFilter> filters,) async {@@ -46,7 +72,7 @@ Future<List<EnteFile>> getFilteredFiles(if (filter is FaceFilter && filter.matchedUploadedIDs.isEmpty) {try {if (filter.personId != null) {- final fileIDs = await mlDataDB.getFileIDsOfPersonID(+ final fileIDs = await _getFileIDsOfPersonIncludingManualAssignments(filter.personId!,);filter.matchedUploadedIDs.addAll(fileIDs);@@ -94,6 +120,11 @@ Future<List<EnteFile>> getFilteredFiles(await mlDataDB.getAllFilesAssociatedWithAllClusters(exceptClusters: selectedClusterIDs,);+ fileIDsToAvoid.addAll(+ await _getManualAssignmentFileIDsOfOtherPersons(+ selectedPersonIDs.toSet(),+ ),+ );final filesOfFaceIDsNotInAnyCluster =await mlDataDB.getAllFileIDsOfFaceIDsNotInAnyCluster();@@ -418,7 +449,13 @@ Future<List<FaceFilter>> curateFaceFilters(final Map<String, List<EnteFile>> clusterIdToFiles = {};final Map<String, List<EnteFile>> personIdToFiles = {};+ final Map<String, Set<int>> personIdToFileIDs = {};+ final Map<int, EnteFile> uploadedIdToFile = {};for (final f in files) {+ final uploadedFileID = f.uploadedFileID;+ if (uploadedFileID != null && uploadedFileID != -1) {+ uploadedIdToFile[uploadedFileID] = f;+ }if (!fileIdToClusterID.containsKey(f.uploadedFileID ?? -1)) {continue;}@@ -427,11 +464,17 @@ Future<List<FaceFilter>> curateFaceFilters(final PersonEntity? p =personIdToPerson[clusterIDToPersonID[clusterId] ?? ""];if (p != null) {- if (personIdToFiles.containsKey(p.remoteID)) {- personIdToFiles[p.remoteID]!.add(f);- } else {- personIdToFiles[p.remoteID] = [f];+ final uploadedFileID = f.uploadedFileID;+ if (uploadedFileID == null || uploadedFileID == -1) {+ personIdToFiles.putIfAbsent(p.remoteID, () => <EnteFile>[]).add(f);+ continue;+ }+ final fileIDsForPerson =+ personIdToFileIDs.putIfAbsent(p.remoteID, () => <int>{});+ if (!fileIDsForPerson.add(uploadedFileID)) {+ continue;}+ personIdToFiles.putIfAbsent(p.remoteID, () => <EnteFile>[]).add(f);} else {if (clusterIdToFiles.containsKey(clusterId)) {clusterIdToFiles[clusterId]!.add(f);@@ -442,6 +485,28 @@ Future<List<FaceFilter>> curateFaceFilters(}}+ for (final entry in personIdToPerson.entries) {+ final manualIDs = entry.value.data.manuallyAssigned.toSet();+ if (manualIDs.isEmpty) {+ continue;+ }++ final filesForPerson =+ personIdToFiles.putIfAbsent(entry.key, () => <EnteFile>[]);+ final fileIDsForPerson =+ personIdToFileIDs.putIfAbsent(entry.key, () => <int>{});++ for (final manualID in manualIDs) {+ if (!fileIDsForPerson.add(manualID)) {+ continue;+ }+ final file = uploadedIdToFile[manualID];+ if (file != null) {+ filesForPerson.add(file);+ }+ }+ }+for (final personID in personIdToFiles.keys) {final files = personIdToFiles[personID]!;if (files.isEmpty) {