Skip to content

armgit / ente

Public Imported from GitHub
0

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

Align contact link picker with people list

laurenspriem5d82b011fa7b
diff --git a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
index 989c2a09b1..255085a444 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
@@ -8,8 +8,11 @@ import "package:photos/events/people_changed_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/ml/face/person.dart";
+import "package:photos/models/search/search_constants.dart";
import "package:photos/models/typedefs.dart";
+import "package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart";
import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
+import "package:photos/services/search_service.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
@@ -41,17 +44,46 @@ class _LinkContactToPersonSelectionPageState
void initState() {
super.initState();
- _personEntities = PersonService.instance.getPersons().then((persons) async {
- final List<PersonEntity> result = [];
- for (final person in persons) {
- if ((person.data.email != null && person.data.email!.isNotEmpty) ||
- (person.data.isIgnored)) {
- continue;
- }
- result.add(person);
+ _personEntities = _loadSelectablePersons();
+ }
+
+ Future<List<PersonEntity>> _loadSelectablePersons() async {
+ final faces = await SearchService.instance
+ .getAllFace(null, minClusterSize: kMinimumClusterSizeAllFaces);
+ final seenPersonIds = <String>{};
+ final orderedPersonIds = <String>[];
+
+ for (final face in faces) {
+ final personID = face.params[kPersonParamID] as String?;
+ if (personID == null) {
+ continue;
}
- return result;
- });
+ if (seenPersonIds.add(personID)) {
+ orderedPersonIds.add(personID);
+ }
+ }
+
+ if (orderedPersonIds.isEmpty) {
+ return const [];
+ }
+
+ final personsMap = await PersonService.instance.getPersonsMap();
+ final List<PersonEntity> result = [];
+ for (final personID in orderedPersonIds) {
+ final person = personsMap[personID];
+ if (person == null) {
+ _logger
+ .warning("Person $personID missing from cache while loading faces");
+ continue;
+ }
+ if ((person.data.email != null && person.data.email!.isNotEmpty) ||
+ person.data.isIgnored) {
+ continue;
+ }
+ result.add(person);
+ }
+
+ return result;
}
@override