[mob][photos] Push not person feedback

This commit is contained in:
laurenspriem
2024-11-11 15:42:24 +05:30
parent 81ea2b8059
commit 908a55bb20
2 changed files with 18 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ class PersonData {
final bool isHidden;
String? avatarFaceID;
List<ClusterInfo>? assigned = List<ClusterInfo>.empty();
List<ClusterInfo>? rejected = List<ClusterInfo>.empty();
List<String>? rejectedFaceIDs = List<String>.empty();
final String? birthDate;
bool hasAvatar() => avatarFaceID != null;
@@ -62,7 +62,7 @@ class PersonData {
PersonData({
required this.name,
this.assigned,
this.rejected,
this.rejectedFaceIDs,
this.avatarFaceID,
this.isHidden = false,
this.birthDate,
@@ -79,7 +79,7 @@ class PersonData {
return PersonData(
name: name ?? this.name,
assigned: assigned ?? this.assigned,
avatarFaceID: avatarFaceId ?? this.avatarFaceID,
avatarFaceID: avatarFaceId ?? avatarFaceID,
isHidden: isHidden ?? this.isHidden,
birthDate: birthDate ?? this.birthDate,
);
@@ -95,7 +95,7 @@ class PersonData {
assignedCount += a.faces.length;
}
sb.writeln('Assigned: ${assigned?.length} withFaces $assignedCount');
sb.writeln('Rejected: ${rejected?.length}');
sb.writeln('Rejected faceIDs: ${rejectedFaceIDs?.length}');
if (assigned != null) {
for (var cluster in assigned!) {
sb.writeln('Cluster: ${cluster.id} - ${cluster.faces.length}');
@@ -108,7 +108,7 @@ class PersonData {
Map<String, dynamic> toJson() => {
'name': name,
'assigned': assigned?.map((e) => e.toJson()).toList(),
'rejected': rejected?.map((e) => e.toJson()).toList(),
'rejectedFaceIDs': rejectedFaceIDs,
'avatarFaceID': avatarFaceID,
'isHidden': isHidden,
'birthDate': birthDate,
@@ -122,15 +122,16 @@ class PersonData {
json['assigned'].map((x) => ClusterInfo.fromJson(x)),
);
final rejected = (json['rejected'] == null || json['rejected'].length == 0)
? <ClusterInfo>[]
: List<ClusterInfo>.from(
json['rejected'].map((x) => ClusterInfo.fromJson(x)),
);
final List<String> rejectedFaceIDs =
(json['rejectedFaceIDs'] == null || json['rejectedFaceIDs'].length == 0)
? <String>[]
: List<String>.from(
json['rejectedFaceIDs'],
);
return PersonData(
name: json['name'] as String,
assigned: assigned,
rejected: rejected,
rejectedFaceIDs: rejectedFaceIDs,
avatarFaceID: json['avatarFaceID'] as String?,
isHidden: json['isHidden'] as bool? ?? false,
birthDate: json['birthDate'] as String?,

View File

@@ -201,6 +201,8 @@ class PersonService {
required Set<String> faceIDs,
}) async {
final personData = person.data;
// Remove faces from clusters
final List<String> emptiedClusters = [];
for (final cluster in personData.assigned!) {
cluster.faces.removeWhere((faceID) => faceIDs.contains(faceID));
@@ -219,6 +221,10 @@ class PersonService {
);
}
// Add removed faces to rejected faces
personData.rejectedFaceIDs ??= [];
personData.rejectedFaceIDs!.addAll(faceIDs);
await entityService.addOrUpdate(
EntityType.cgroup,
personData.toJson(),