kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix connections background update making too many fast calls.
rodzic
5e2efeceff
commit
cfa1ad79ca
|
@ -94,7 +94,7 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
|||
if (nss.connectionUpdateStatus.value) {
|
||||
return;
|
||||
}
|
||||
manager.updateAllContacts();
|
||||
manager.updateAllContacts(false);
|
||||
return;
|
||||
},
|
||||
child: Column(
|
||||
|
@ -129,7 +129,8 @@ class _ContactsScreenState extends State<ContactsScreen> {
|
|||
padding: const EdgeInsets.all(8.0),
|
||||
child: StatusAndRefreshButton(
|
||||
valueListenable: nss.connectionUpdateStatus,
|
||||
refreshFunction: () async => manager.updateAllContacts(),
|
||||
refreshFunction: () async =>
|
||||
manager.updateAllContacts(false),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
|
|
@ -154,7 +154,7 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
return conRepo.getMyContacts();
|
||||
}
|
||||
|
||||
Future<void> updateAllContacts() async {
|
||||
Future<void> updateAllContacts(bool backgroundUpdate) async {
|
||||
_logger.fine('Updating all contacts');
|
||||
_lastUpdateStatus = 'Updating';
|
||||
final persistentInfo = getIt<ActiveProfileSelector<PersistentInfoService>>()
|
||||
|
@ -163,6 +163,9 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
final originalTime = persistentInfo.lastMyConnectionsUpdate;
|
||||
await persistentInfo.updateLastMyConnectionUpdate(DateTime.now());
|
||||
notifyListeners();
|
||||
final delay = backgroundUpdate
|
||||
? const Duration(minutes: 5)
|
||||
: const Duration(seconds: 10);
|
||||
try {
|
||||
final client = RelationshipsClient(profile);
|
||||
final results = <String, Connection>{};
|
||||
|
@ -186,7 +189,7 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
}, onError: (error) {
|
||||
_logger.severe('Error getting followers data: $error');
|
||||
});
|
||||
await Future.delayed(Duration.zero);
|
||||
await Future.delayed(delay);
|
||||
}
|
||||
|
||||
moreResults = true;
|
||||
|
@ -210,7 +213,7 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
}, onError: (error) {
|
||||
_logger.severe('Error getting followers data: $error');
|
||||
});
|
||||
await Future.delayed(Duration.zero);
|
||||
await Future.delayed(delay);
|
||||
}
|
||||
|
||||
for (final noLongerFollowed in originalContacts) {
|
||||
|
|
|
@ -41,7 +41,7 @@ Future<void> executeUpdatesForProfile(Profile profile) async {
|
|||
if (dt >= _connectionsRefreshInterval) {
|
||||
await getIt<ActiveProfileSelector<ConnectionsManager>>()
|
||||
.getForProfile(profile)
|
||||
.withResultAsync((m) async => await m.updateAllContacts())
|
||||
.withResultAsync((m) async => await m.updateAllContacts(true))
|
||||
.withError((error) {
|
||||
_logger.severe('Error running connections update: $error');
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue