Skip to content

Commit

Permalink
Don't do anything with custom for now
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Apr 23, 2023
1 parent 87d4dae commit 8586905
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
19 changes: 17 additions & 2 deletions Sources/ParseCareKit/Models/PCKRevisionRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ struct PCKRevisionRecord: ParseObject, Equatable, Codable {
}
}

public var vector: String?
var vector: String?

var storeClassesToSynchronize: [PCKStoreClass: any PCKVersionable.Type]? = try? PCKStoreClass.getConcrete()

var customClassesToSynchronize: [String: any PCKVersionable.Type]?

var objects: [any PCKVersionable] {
guard let entities = entities else {
Expand Down Expand Up @@ -112,6 +116,13 @@ struct PCKRevisionRecord: ParseObject, Equatable, Codable {
logicalClock, clock, clockUUID
}

static func == (lhs: PCKRevisionRecord, rhs: PCKRevisionRecord) -> Bool {
lhs.vector == rhs.vector &&
lhs.logicalClock == rhs.logicalClock &&
lhs.objectId == rhs.objectId &&
lhs.entities == rhs.entities
}

func convertToCareKit() throws -> OCKRevisionRecord {
guard let entities = entities,
let knowledgeVector = knowledgeVector else {
Expand Down Expand Up @@ -246,13 +257,17 @@ extension PCKRevisionRecord {
init(record: OCKRevisionRecord,
remoteClockUUID: UUID,
remoteClock: PCKClock,
remoteClockValue: Int) throws {
remoteClockValue: Int,
storeClassesToSynchronize: [PCKStoreClass: any PCKVersionable.Type]? = nil,
customClassesToSynchronize: [String: any PCKVersionable.Type]? = nil) throws {
self.objectId = UUID().uuidString
self.ACL = PCKUtility.getDefaultACL()
self.clockUUID = remoteClockUUID
self.logicalClock = remoteClockValue
self.clock = remoteClock
self.knowledgeVector = record.knowledgeVector
self.storeClassesToSynchronize = storeClassesToSynchronize
self.customClassesToSynchronize = customClassesToSynchronize
self.entities = try record.entities.compactMap { entity in
var parseEntity = try entity.parseEntity().value
parseEntity.logicalClock = remoteClockValue // Stamp Entity
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseCareKit/Models/PCKStoreClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import os.log
// swiftlint:disable line_length

/// Types of ParseCareKit classes.
public enum PCKStoreClass: String, CaseIterable {
public enum PCKStoreClass: String, Equatable, CaseIterable {
/// The ParseCareKit equivalent of `OCKPatient`.
case patient
/// The ParseCareKit equivalent of `OCKCarePlan`.
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseCareKit/ParseRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ParseRemote: OCKRemoteSynchronizable {
public var uuid: UUID!

/// A dictionary of any custom classes to synchronize between the `CareKitStore` and the Parse Server.
public var customClassesToSynchronize: [String: any PCKVersionable]?
public var customClassesToSynchronize: [String: any PCKVersionable.Type]?

/// A dictionary of any default classes to synchronize between the `CareKitStore` and the Parse Server. These
/// are `PCKPatient`, `PCKCarePlan`, `PCKContact`, `PCKTask`, `PCKHealthKitTask`,
Expand Down Expand Up @@ -128,7 +128,7 @@ public class ParseRemote: OCKRemoteSynchronizable {
convenience public init(uuid: UUID,
auto: Bool,
replacePCKStoreClasses: [PCKStoreClass: any PCKVersionable.Type]? = nil,
customClasses: [String: any PCKVersionable],
customClasses: [String: any PCKVersionable.Type],
subscribeToServerUpdates: Bool,
defaultACL: ParseACL? = nil) async throws {
try await self.init(uuid: uuid,
Expand Down

0 comments on commit 8586905

Please sign in to comment.