Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] keep face crops for clusters as well

laurenspriemdd8cef3ddf7a
diff --git a/mobile/lib/ui/viewer/search/result/person_face_widget.dart b/mobile/lib/ui/viewer/search/result/person_face_widget.dart
index fd1ac4fc7d..8afad975bc 100644
--- a/mobile/lib/ui/viewer/search/result/person_face_widget.dart
+++ b/mobile/lib/ui/viewer/search/result/person_face_widget.dart
@@ -88,6 +88,7 @@ class _PersonFaceWidgetState extends State<PersonFaceWidget> {
try {
EnteFile? fileForFaceCrop = widget.file;
String? personAvatarFaceID;
+ Iterable<String>? allFaces;
if (widget.personId != null) {
final PersonEntity? personEntity =
await PersonService.instance.getPerson(widget.personId!);
@@ -99,30 +100,35 @@ class _PersonFaceWidgetState extends State<PersonFaceWidget> {
if (tryCache != null) return tryCache;
}
if (personAvatarFaceID == null && widget.cannotTrustFile) {
- final allFaces =
+ allFaces =
await MLDataDB.instance.getFaceIDsForPerson(widget.personId!);
- final allFileIDs = allFaces.map((e) => getFileIdFromFaceId(e));
- final fileIDToCreationTime =
- await FilesDB.instance.getFileIDToCreationTime();
- // Get the file with the most recent creation time
- final recentFileID = allFileIDs.reduce((a, b) {
- final aTime = fileIDToCreationTime[a];
- final bTime = fileIDToCreationTime[b];
- if (aTime == null) {
- return b;
- }
- if (bTime == null) {
- return a;
- }
- return (aTime >= bTime) ? a : b;
- });
- if (fileForFaceCrop.uploadedFileID != recentFileID) {
- fileForFaceCrop =
- await FilesDB.instance.getAnyUploadedFile(recentFileID);
- if (fileForFaceCrop == null) return null;
- }
}
}
+ } else if (widget.clusterID != null && widget.cannotTrustFile) {
+ allFaces =
+ await MLDataDB.instance.getFaceIDsForCluster(widget.clusterID!);
+ }
+ if (allFaces != null) {
+ final allFileIDs = allFaces.map((e) => getFileIdFromFaceId(e));
+ final fileIDToCreationTime =
+ await FilesDB.instance.getFileIDToCreationTime();
+ // Get the file with the most recent creation time
+ final recentFileID = allFileIDs.reduce((a, b) {
+ final aTime = fileIDToCreationTime[a];
+ final bTime = fileIDToCreationTime[b];
+ if (aTime == null) {
+ return b;
+ }
+ if (bTime == null) {
+ return a;
+ }
+ return (aTime >= bTime) ? a : b;
+ });
+ if (fileForFaceCrop.uploadedFileID != recentFileID) {
+ fileForFaceCrop =
+ await FilesDB.instance.getAnyUploadedFile(recentFileID);
+ if (fileForFaceCrop == null) return null;
+ }
}
final Face? face = await MLDataDB.instance.getCoverFaceForPerson(