Skip to content

Commit 9e59f6e

Browse files
committed
fix updating remote clock
1 parent f7c58ae commit 9e59f6e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/ParseCareKit/ParseRemote.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,22 @@ public class ParseRemote: OCKRemoteSynchronizable {
515515
localClock: OCKRevisionRecord.KnowledgeVector,
516516
completion: @escaping (Error?) -> Void) {
517517
Task {
518-
var cloudVector = cloudVector
518+
var updatedCloudVector = cloudVector
519519
if shouldIncrementCloudClock {
520520
// Increment and merge Knowledge Vector
521-
cloudVector.increment(clockFor: self.uuid)
521+
updatedCloudVector.increment(clockFor: self.uuid)
522522
}
523-
cloudVector.merge(with: localClock)
523+
updatedCloudVector.merge(with: localClock)
524524

525-
guard let updatedClock = PCKClock.encodeVector(cloudVector, for: parseClock) else {
525+
guard let updatedClock = PCKClock.encodeVector(updatedCloudVector, for: parseClock) else {
526526
await self.remoteStatus.setNotSynchronzing()
527527
completion(ParseCareKitError.couldntUnwrapClock)
528528
return
529529
}
530530

531531
// If clocks incremented or new clock introduced, no need to save to Cloud.
532-
guard shouldIncrementCloudClock || (!shouldIncrementCloudClock && cloudVector.uuids.count != localClock.uuids.count) else {
532+
guard shouldIncrementCloudClock ||
533+
(!shouldIncrementCloudClock && cloudVector.uuids.count != updatedCloudVector.uuids.count) else {
533534
await self.remoteStatus.setNotSynchronzing()
534535
// Clocks not updated, no need to update cloud.
535536
if #available(iOS 14.0, watchOS 7.0, *) {

0 commit comments

Comments
 (0)