Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Apr 25, 2023
1 parent 2ae4b9e commit 0b06329
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/ParseCareKit/ParseRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,18 @@ public class ParseRemote: OCKRemoteSynchronizable {
do {
_ = try await updatedClock.save()
Logger.pushRevisions.debug("Finished pushing revisions")
await self.remoteStatus.notSynchronzing()
await self.subscribeToClock()
DispatchQueue.main.async {
self.parseRemoteDelegate?.successfullyPushedToRemote()
}
completion(nil)
} catch {
await self.remoteStatus.updateClock(parseClock) // revert
Logger.pushRevisions.error("finishedRevisions: \(error, privacy: .private)")
await self.remoteStatus.notSynchronzing()
completion(error)
}
await self.remoteStatus.notSynchronzing()
await self.subscribeToClock()
}
}

Expand Down Expand Up @@ -456,7 +457,9 @@ public class ParseRemote: OCKRemoteSynchronizable {
do {
let delay = try await self.remoteStatus.retryLiveQueryAfter()
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(delay)) {
self.parseRemoteDelegate?.didRequestSynchronization(self)
Task {
await self.requestSyncIfNewerClock(updatedClock)
}
}
} catch {
Logger.clockSubscription.error("\(error)")
Expand All @@ -481,7 +484,7 @@ public class ParseRemote: OCKRemoteSynchronizable {

func requestSyncIfNewerClock(_ clock: PCKClock?) async {
guard let vector = clock?.knowledgeVector,
await self.remoteStatus.hasNewerClock(vector, for: self.uuid) else {
await self.remoteStatus.hasNewerClock(vector, for: uuid) else {
return
}
let random = Int.random(in: 0..<2)
Expand Down

0 comments on commit 0b06329

Please sign in to comment.