|
|
|
|
@ -62,7 +62,6 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection { |
|
|
|
|
/// Reschedule Api calls if not empty |
|
|
|
|
func loadFromFile() throws { |
|
|
|
|
try self._decodeJSONFile() |
|
|
|
|
// self.rescheduleApiCallsIfNecessary() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Returns the file URL of the collection |
|
|
|
|
@ -155,15 +154,19 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func resumeApiCalls() { |
|
|
|
|
self._schedulingTask?.cancel() |
|
|
|
|
self._attemptLoops = -1 |
|
|
|
|
self.rescheduleApiCallsIfNecessary() |
|
|
|
|
if self._schedulingTask != nil && self._attemptLoops > 2 { |
|
|
|
|
self._schedulingTask?.cancel() |
|
|
|
|
self._attemptLoops = -1 |
|
|
|
|
self.rescheduleApiCallsIfNecessary() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Reschedule API calls if necessary |
|
|
|
|
func rescheduleApiCallsIfNecessary() { |
|
|
|
|
self._schedulingTask = Task { |
|
|
|
|
await self._rescheduleApiCalls() |
|
|
|
|
if self.items.isNotEmpty { |
|
|
|
|
self._schedulingTask = Task { |
|
|
|
|
await self._rescheduleApiCalls() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -285,7 +288,7 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Sends an insert api call for the provided [instance] |
|
|
|
|
func sendGetIfNecessary(instance: T) async throws where T : URLParameterConvertible { |
|
|
|
|
func sendGetRequest(instance: T) async throws where T : URLParameterConvertible { |
|
|
|
|
do { |
|
|
|
|
let apiCall = ApiCall<T>(method: .get) |
|
|
|
|
apiCall.urlParameters = instance.queryParameters() |
|
|
|
|
|