From 07458fb247a40afc5b171deb05501f7edd16ab84 Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Wed, 24 Apr 2024 17:15:11 +0530 Subject: [PATCH] [mob][photos] Recompute suggestions on rejected suggestion --- .../people/person_cluster_suggestion.dart | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart index 583aaccf6..e310c5af8 100644 --- a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart +++ b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart @@ -116,20 +116,25 @@ class _PersonClustersState extends State { clusterID: clusterID, ); Bus.instance.fire(PeopleChangedEvent()); + // Increment the suggestion index + if (mounted) { + setState(() => currentSuggestionIndex++); + } + + // Check if we need to fetch new data + if (currentSuggestionIndex >= (numberOfSuggestions)) { + setState(() { + currentSuggestionIndex = 0; + futureBuilderKey = UniqueKey(); // Reset to trigger FutureBuilder + _fetchClusterSuggestions(); + }); + } } else { await FaceMLDataDB.instance.captureNotPersonFeedback( personID: widget.person.remoteID, clusterID: clusterID, ); - } - - // Increment the suggestion index - if (mounted) { - setState(() => currentSuggestionIndex++); - } - - // Check if we need to fetch new data - if (currentSuggestionIndex >= (numberOfSuggestions)) { + // Recalculate the suggestions when a suggestion is rejected setState(() { currentSuggestionIndex = 0; futureBuilderKey = UniqueKey(); // Reset to trigger FutureBuilder