From d1091b926eb38025cce35b502f9df79f6ad873c2 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 31 Jan 2025 10:10:08 +0100 Subject: [PATCH] Call scheduling improvement --- LeStorage/ApiCallCollection.swift | 5 +++++ LeStorage/StoreCenter.swift | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/LeStorage/ApiCallCollection.swift b/LeStorage/ApiCallCollection.swift index 9cc81b3..1886c64 100644 --- a/LeStorage/ApiCallCollection.swift +++ b/LeStorage/ApiCallCollection.swift @@ -161,6 +161,11 @@ actor ApiCallCollection: SomeCallCollection { } } + func rescheduleImmediately() { + self._attemptLoops = -1 + self.rescheduleApiCallsIfNecessary() + } + /// Reschedule API calls if necessary func rescheduleApiCallsIfNecessary() { if self.items.isNotEmpty && !self._isRescheduling { diff --git a/LeStorage/StoreCenter.swift b/LeStorage/StoreCenter.swift index 0b9973f..6154cd7 100644 --- a/LeStorage/StoreCenter.swift +++ b/LeStorage/StoreCenter.swift @@ -129,7 +129,7 @@ public class StoreCenter { } @objc fileprivate func _willEnterForegroundNotification() { - Logger.log("_willEnterForegroundNotification") +// Logger.log("_willEnterForegroundNotification") self._launchSynchronization() } @@ -464,7 +464,7 @@ public class StoreCenter { let syncGetCollection: ApiCallCollection = try self.apiCallCollection() if await syncGetCollection.hasPendingCalls() { - await syncGetCollection.rescheduleApiCallsIfNecessary() + await syncGetCollection.rescheduleImmediately() } else { let getSyncData = GetSyncData() getSyncData.lastUpdate = lastSync