π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Make sure user can add back rejected faces
laurenspriem822aa7fcd477
diff --git a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dartindex 2f17010180..8e9171611c 100644--- a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart+++ b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart@@ -334,6 +334,31 @@ class ClusterFeedbackService {return true;}+ Future<void> addClusterToExistingPerson({+ required PersonEntity person,+ required String clusterID,+ }) async {+ if (person.data.rejectedFaceIDs != null &&+ person.data.rejectedFaceIDs!.isNotEmpty) {+ final clusterFaceIDs =+ await MLDataDB.instance.getFaceIDsForCluster(clusterID);+ final rejectedLengthBefore = person.data.rejectedFaceIDs!.length;+ person.data.rejectedFaceIDs!+ .removeWhere((faceID) => clusterFaceIDs.contains(faceID));+ final rejectedLengthAfter = person.data.rejectedFaceIDs!.length;+ if (rejectedLengthBefore != rejectedLengthAfter) {+ _logger.info(+ 'Removed ${rejectedLengthBefore - rejectedLengthAfter} rejected faces from person ${person.data.name} due to adding cluster $clusterID',+ );+ await PersonService.instance.updatePerson(person);+ }+ }+ await MLDataDB.instance.assignClusterToPerson(+ personID: person.remoteID,+ clusterID: clusterID,+ );+ }+Future<void> ignoreCluster(String clusterID) async {await PersonService.instance.addPerson('', clusterID, isHidden: true);Bus.instance.fire(PeopleChangedEvent());diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dartindex 7a9b7ee7b5..07c96a066f 100644--- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart+++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart@@ -381,7 +381,7 @@ class PersonService {final updatedPerson = person.copyWith(data: person.data.copyWith(avatarFaceId: face.faceID),);- await _updatePerson(updatedPerson);+ await updatePerson(updatedPerson);}Future<void> updateAttributes(@@ -402,10 +402,10 @@ class PersonService {birthDate: birthDate,),);- await _updatePerson(updatedPerson);+ await updatePerson(updatedPerson);}- Future<void> _updatePerson(PersonEntity updatePerson) async {+ Future<void> updatePerson(PersonEntity updatePerson) async {await entityService.addOrUpdate(EntityType.cgroup,updatePerson.data.toJson(),diff --git a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart b/mobile/lib/ui/viewer/people/add_person_action_sheet.dartindex 9aa05b16e4..0039d477fb 100644--- a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart+++ b/mobile/lib/ui/viewer/people/add_person_action_sheet.dart@@ -7,7 +7,6 @@ import 'package:flutter/material.dart';import "package:logging/logging.dart";import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';import "package:photos/core/event_bus.dart";-import "package:photos/db/ml/db.dart";import "package:photos/events/people_changed_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/file/file.dart";@@ -255,8 +254,9 @@ class _PersonActionSheetState extends State<PersonActionSheet> {return;}userAlreadyAssigned = true;- await MLDataDB.instance.assignClusterToPerson(- personID: person.$1.remoteID,+ await ClusterFeedbackService.instance+ .addClusterToExistingPerson(+ person: person.$1,clusterID: widget.cluserID,);Bus.instance.fire(PeopleChangedEvent());diff --git a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dartindex 54ff9975e8..47857ce82b 100644--- a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart+++ b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart@@ -199,8 +199,8 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {);if (yesOrNo) {canGiveFeedback = false;- await MLDataDB.instance.assignClusterToPerson(- personID: widget.person.remoteID,+ await ClusterFeedbackService.instance.addClusterToExistingPerson(+ person: widget.person,clusterID: clusterID,);Bus.instance.fire(PeopleChangedEvent());