Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fire event only once

laurenspriemf22a065c1562
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.dart
index fcd5155fc9..b0fdd460ed 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
@@ -467,6 +467,7 @@ class ClusterFeedbackService<T> {
Future<void> addClusterToExistingPerson({
required PersonEntity person,
required String clusterID,
+ bool fireEvent = true,
}) async {
if (person.data.rejectedFaceIDs.isNotEmpty) {
final clusterFaceIDs = await mlDataDB.getFaceIDsForCluster(clusterID);
@@ -485,12 +486,14 @@ class ClusterFeedbackService<T> {
personID: person.remoteID,
clusterID: clusterID,
);
- Bus.instance.fire(
- PeopleChangedEvent(
- type: PeopleEventType.addedClusterToPerson,
- source: person.remoteID,
- ),
- );
+ if (fireEvent) {
+ Bus.instance.fire(
+ PeopleChangedEvent(
+ type: PeopleEventType.addedClusterToPerson,
+ source: person.remoteID,
+ ),
+ );
+ }
}
Future<void> ignoreCluster(String clusterID) async {
diff --git a/mobile/lib/ui/viewer/actions/people_selection_action_widget.dart b/mobile/lib/ui/viewer/actions/people_selection_action_widget.dart
index 8249b61296..42ee6ebb25 100644
--- a/mobile/lib/ui/viewer/actions/people_selection_action_widget.dart
+++ b/mobile/lib/ui/viewer/actions/people_selection_action_widget.dart
@@ -261,9 +261,15 @@ class _PeopleSelectionActionWidgetState
await ClusterFeedbackService.instance.addClusterToExistingPerson(
clusterID: clusterID,
person: person,
+ fireEvent: false,
);
}
- Bus.instance.fire(PeopleChangedEvent());
+ Bus.instance.fire(
+ PeopleChangedEvent(
+ type: PeopleEventType.addedClusterToPerson,
+ source: person.remoteID,
+ ),
+ );
widget.selectedPeople.clearAll();
} catch (e, s) {
_logger.severe('Merging clusters failed', e, s);