From 9df3d9fb2da4629cd6033ab4d8e847c073d0bcfa Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 24 Dec 2024 15:33:04 -0500 Subject: [PATCH] Improve statusing during bulk contacts update --- .../connection_manager_services.dart | 24 ++++++++++++------- .../connection_manager_services.g.dart | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/riverpod_controllers/connection_manager_services.dart b/lib/riverpod_controllers/connection_manager_services.dart index 20cbc49..437935a 100644 --- a/lib/riverpod_controllers/connection_manager_services.dart +++ b/lib/riverpod_controllers/connection_manager_services.dart @@ -354,7 +354,11 @@ class AllContactsUpdater extends _$AllContactsUpdater { .match(onSuccess: (followers) { for (final f in followers.data) { originalContacts.remove(f); - results[f.id] = f.copy(status: ConnectionStatus.theyFollowYou); + final c = f.copy(status: ConnectionStatus.theyFollowYou); + results[c.id] = c; + ref + .read(connectionModifierProvider(profile, c).notifier) + .upsertConnection(c); int id = int.parse(f.id); maxId = max(maxId, id); } @@ -362,6 +366,9 @@ class AllContactsUpdater extends _$AllContactsUpdater { currentPage = followers.next!; } moreResults = followers.next != null; + ref + .read(_updateStatusInternalProvider(profile).notifier) + .update('Updating: ${results.length} processed'); }, onError: (error) { _acuLogger.severe( 'Error getting followers data: $error', @@ -370,12 +377,6 @@ class AllContactsUpdater extends _$AllContactsUpdater { moreResults = false; }); - for (final c in results.values) { - ref - .read(connectionModifierProvider(profile, c).notifier) - .upsertConnection(c); - } - await Future.delayed(delay); } @@ -390,9 +391,11 @@ class AllContactsUpdater extends _$AllContactsUpdater { final newStatus = results.containsKey(f.id) ? ConnectionStatus.mutual : ConnectionStatus.youFollowThem; + final c = f.copy(status: newStatus); + results[c.id] = c; ref - .read(connectionModifierProvider(profile, f).notifier) - .upsertConnection(f.copy(status: newStatus)); + .read(connectionModifierProvider(profile, c).notifier) + .upsertConnection(c); int id = int.parse(f.id); maxId = max(maxId, id); } @@ -400,6 +403,9 @@ class AllContactsUpdater extends _$AllContactsUpdater { currentPage = following.next!; } moreResults = following.next != null; + ref + .read(_updateStatusInternalProvider(profile).notifier) + .update('Updating: ${results.length} processed'); }, onError: (error) { _acuLogger.severe( 'Error getting your following data: $error', diff --git a/lib/riverpod_controllers/connection_manager_services.g.dart b/lib/riverpod_controllers/connection_manager_services.g.dart index 85f44b9..006b4f7 100644 --- a/lib/riverpod_controllers/connection_manager_services.g.dart +++ b/lib/riverpod_controllers/connection_manager_services.g.dart @@ -1766,7 +1766,7 @@ class _UpdateStatusInternalProviderElement } String _$allContactsUpdaterHash() => - r'40fac002c2cb5d493d034618182a9e1c64b58633'; + r'9d5b4f79302f89d8817022dcd9a90af6e05ef949'; abstract class _$AllContactsUpdater extends BuildlessNotifier { late final Profile profile;