[mob][photos] Suggestion option to assign to different person

This commit is contained in:
laurenspriem 2024-05-14 11:51:50 +05:30
parent a3eba12ccf
commit f4024d2007

View file

@ -14,6 +14,7 @@ import "package:photos/services/machine_learning/face_ml/person/person_service.d
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/viewer/people/add_person_action_sheet.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";
@ -193,22 +194,29 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
setState(() {});
}
} else {
canGiveFeedback = false;
await FaceMLDataDB.instance.captureNotPersonFeedback(
personID: widget.person.remoteID,
clusterID: clusterID,
);
// Recalculate the suggestions when a suggestion is rejected
setState(() {
currentSuggestionIndex = 0;
futureBuilderKeySuggestions =
UniqueKey(); // Reset to trigger FutureBuilder
futureBuilderKeyFaceThumbnails = UniqueKey();
_fetchClusterSuggestions();
});
await _rejectSuggestion(clusterID, numberOfSuggestions);
}
}
Future<void> _rejectSuggestion(
int clusterID,
int numberOfSuggestions,
) async {
canGiveFeedback = false;
await FaceMLDataDB.instance.captureNotPersonFeedback(
personID: widget.person.remoteID,
clusterID: clusterID,
);
// Recalculate the suggestions when a suggestion is rejected
setState(() {
currentSuggestionIndex = 0;
futureBuilderKeySuggestions =
UniqueKey(); // Reset to trigger FutureBuilder
futureBuilderKeyFaceThumbnails = UniqueKey();
_fetchClusterSuggestions();
});
}
// Method to fetch cluster suggestions
void _fetchClusterSuggestions() {
futureClusterSuggestions =
@ -245,7 +253,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
),
const SizedBox(
height: 24.0,
), // Add some spacing between the thumbnail and the text
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Row(
@ -282,6 +290,25 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
],
),
),
const SizedBox(
height: 24.0,
),
ButtonWidget(
shouldSurfaceExecutionStates: false,
buttonType: ButtonType.neutral,
labelText: 'Assign different person',
buttonSize: ButtonSize.small,
onTap: () async {
final result = await showAssignPersonAction(
context,
clusterID: clusterID,
);
if (result == null || result is! PersonEntity) {
return;
}
await _rejectSuggestion(clusterID, numberOfSuggestions);
},
),
],
);
// Precompute face thumbnails for next suggestions, in case there are