Browse Source

[mob] Fetch remote entities before running clustering

Neeraj Gupta 1 year ago
parent
commit
bb3a37adf5

+ 1 - 0
mobile/lib/services/machine_learning/face_ml/person/person_service.dart

@@ -85,6 +85,7 @@ class PersonService {
   }
   }
 
 
   Future<void> storeRemoteFeedback() async {
   Future<void> storeRemoteFeedback() async {
+    await entityService.syncEntities();
     final entities = await entityService.getEntities(EntityType.person);
     final entities = await entityService.getEntities(EntityType.person);
     entities.sort((a, b) => a.updatedAt.compareTo(b.updatedAt));
     entities.sort((a, b) => a.updatedAt.compareTo(b.updatedAt));
     final Map<String, int> faceIdToClusterID = {};
     final Map<String, int> faceIdToClusterID = {};

+ 10 - 5
mobile/lib/ui/settings/debug/face_debug_section_widget.dart

@@ -161,11 +161,16 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
           trailingIcon: Icons.chevron_right_outlined,
           trailingIcon: Icons.chevron_right_outlined,
           trailingIconIsMuted: true,
           trailingIconIsMuted: true,
           onTap: () async {
           onTap: () async {
-            await PersonService.instance.storeRemoteFeedback();
-            await FaceMlService.instance
-                .clusterAllImages(clusterInBuckets: true);
-            Bus.instance.fire(PeopleChangedEvent());
-            showShortToast(context, "Done");
+            try {
+              await PersonService.instance.storeRemoteFeedback();
+              await FaceMlService.instance
+                  .clusterAllImages(clusterInBuckets: true);
+              Bus.instance.fire(PeopleChangedEvent());
+              showShortToast(context, "Done");
+            } catch (e, s) {
+              _logger.warning('clustering failed ', e, s);
+              await showGenericErrorDialog(context: context, error: e);
+            }
           },
           },
         ),
         ),
         sectionOptionSpacing,
         sectionOptionSpacing,