Skip to content

Commit

Permalink
Don't save clock to server when no revision updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Apr 22, 2023
1 parent 1ff1cf6 commit 4f1c762
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Sources/ParseCareKit/ParseRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,21 +389,24 @@ public class ParseRemote: OCKRemoteSynchronizable {
localClock: OCKRevisionRecord.KnowledgeVector,
completion: @escaping (Error?) -> Void) {
Task {
var updatedParseVector = parseVector
if shouldIncrementClock {
// Increment and merge Knowledge Vector
updatedParseVector = incrementVectorClock(updatedParseVector)
updatedParseVector.merge(with: localClock)
} else {
updatedParseVector.merge(with: localClock)
if updatedParseVector.uuids.count > parseVector.uuids.count {
// Increment and merge Knowledge Vector
updatedParseVector = incrementVectorClock(updatedParseVector)
guard shouldIncrementClock else {
await self.remoteStatus.updateClock(parseClock)
await self.remoteStatus.notSynchronzing()
Logger.pushRevisions.debug("Finished pushing revisions")
DispatchQueue.main.async {
self.parseRemoteDelegate?.successfullyPushedDataToCloud()
}
completion(nil)
return
}
var updatedParseVector = parseVector
// Increment and merge Knowledge Vector
updatedParseVector = incrementVectorClock(updatedParseVector)
updatedParseVector.merge(with: localClock)
guard let updatedClock = PCKClock.encodeVector(updatedParseVector, for: parseClock) else {
await self.remoteStatus.updateClock(parseClock) // revert
await self.remoteStatus.notSynchronzing()
Logger.pushRevisions.error("Could not encode clock")
completion(ParseCareKitError.couldntUnwrapClock)
return
}
Expand Down

0 comments on commit 4f1c762

Please sign in to comment.