π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] More refactor
laurenspriem12fc4816c7cb
diff --git a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dartindex 54ff9975e8..86d3198989 100644--- a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart+++ b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart@@ -19,6 +19,7 @@ import "package:photos/ui/components/models/button_type.dart";import "package:photos/ui/viewer/people/cluster_page.dart";import "package:photos/ui/viewer/people/person_clusters_page.dart";import "package:photos/ui/viewer/search/result/person_face_widget.dart";+import "package:photos/utils/face/face_box_crop.dart";class SuggestionUserFeedback {final bool accepted;@@ -358,7 +359,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {final clusterID = suggestion.clusterIDToMerge;for (final file in files.sublist(0, min(files.length, 8))) {unawaited(- PersonFaceWidget.precomputeNextFaceCrops(+ precomputeNextFaceCrops(file,clusterID,useFullFile: false,@@ -465,7 +466,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {final futures = <Future<Uint8List?>>[];for (final file in files) {futures.add(- PersonFaceWidget.precomputeNextFaceCrops(+ precomputeNextFaceCrops(file,clusterID,useFullFile: false,diff --git a/mobile/lib/ui/viewer/search/result/person_face_widget.dart b/mobile/lib/ui/viewer/search/result/person_face_widget.dartindex cb25577b09..bd4e971e32 100644--- a/mobile/lib/ui/viewer/search/result/person_face_widget.dart+++ b/mobile/lib/ui/viewer/search/result/person_face_widget.dart@@ -123,43 +123,4 @@ class PersonFaceWidget extends StatelessWidget {}}- static Future<Uint8List?> precomputeNextFaceCrops(- file,- clusterID, {- required bool useFullFile,- }) async {- try {- final Face? face = await MLDataDB.instance.getCoverFaceForPerson(- recentFileID: file.uploadedFileID!,- clusterID: clusterID,- );- if (face == null) {- debugPrint(- "No cover face for cluster $clusterID and recentFile ${file.uploadedFileID}",- );- return null;- }- EnteFile? fileForFaceCrop = file;- if (face.fileID != file.uploadedFileID!) {- fileForFaceCrop =- await FilesDB.instance.getAnyUploadedFile(face.fileID);- }- if (fileForFaceCrop == null) {- return null;- }- final cropMap = await getCachedFaceCrops(- fileForFaceCrop,- [face],- useFullFile: useFullFile,- );- return cropMap?[face.faceID];- } catch (e, s) {- log(- "Error getting cover face for cluster $clusterID",- error: e,- stackTrace: s,- );- return null;- }- }}diff --git a/mobile/lib/utils/face/face_box_crop.dart b/mobile/lib/utils/face/face_box_crop.dartindex 02b1166479..8e25ad2bdc 100644--- a/mobile/lib/utils/face/face_box_crop.dart+++ b/mobile/lib/utils/face/face_box_crop.dart@@ -3,6 +3,8 @@ import "dart:io" show File;import "package:flutter/foundation.dart";import "package:logging/logging.dart";import "package:photos/core/cache/lru_map.dart";+import "package:photos/db/files_db.dart";+import "package:photos/db/ml/db.dart";import "package:photos/models/file/file.dart";import "package:photos/models/file/file_type.dart";import "package:photos/models/ml/face/box.dart";@@ -126,6 +128,46 @@ Future<Map<String, Uint8List>?> getCachedFaceCrops(}}+Future<Uint8List?> precomputeNextFaceCrops(+ file,+ clusterID, {+ required bool useFullFile,+ }) async {+ try {+ final Face? face = await MLDataDB.instance.getCoverFaceForPerson(+ recentFileID: file.uploadedFileID!,+ clusterID: clusterID,+ );+ if (face == null) {+ debugPrint(+ "No cover face for cluster $clusterID and recentFile ${file.uploadedFileID}",+ );+ return null;+ }+ EnteFile? fileForFaceCrop = file;+ if (face.fileID != file.uploadedFileID!) {+ fileForFaceCrop =+ await FilesDB.instance.getAnyUploadedFile(face.fileID);+ }+ if (fileForFaceCrop == null) {+ return null;+ }+ final cropMap = await getCachedFaceCrops(+ fileForFaceCrop,+ [face],+ useFullFile: useFullFile,+ );+ return cropMap?[face.faceID];+ } catch (e, s) {+ _logger.severe(+ "Error getting cover face for cluster $clusterID",+ e,+ s,+ );+ return null;+ }+ }+Future<Map<String, Uint8List>?> _getFaceCrops(EnteFile file,Map<String, FaceBox> faceBoxeMap, {