Skip to content

Commit 8586905

Browse files
committed
Don't do anything with custom for now
1 parent 87d4dae commit 8586905

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Sources/ParseCareKit/Models/PCKRevisionRecord.swift

+17-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ struct PCKRevisionRecord: ParseObject, Equatable, Codable {
5555
}
5656
}
5757

58-
public var vector: String?
58+
var vector: String?
59+
60+
var storeClassesToSynchronize: [PCKStoreClass: any PCKVersionable.Type]? = try? PCKStoreClass.getConcrete()
61+
62+
var customClassesToSynchronize: [String: any PCKVersionable.Type]?
5963

6064
var objects: [any PCKVersionable] {
6165
guard let entities = entities else {
@@ -112,6 +116,13 @@ struct PCKRevisionRecord: ParseObject, Equatable, Codable {
112116
logicalClock, clock, clockUUID
113117
}
114118

119+
static func == (lhs: PCKRevisionRecord, rhs: PCKRevisionRecord) -> Bool {
120+
lhs.vector == rhs.vector &&
121+
lhs.logicalClock == rhs.logicalClock &&
122+
lhs.objectId == rhs.objectId &&
123+
lhs.entities == rhs.entities
124+
}
125+
115126
func convertToCareKit() throws -> OCKRevisionRecord {
116127
guard let entities = entities,
117128
let knowledgeVector = knowledgeVector else {
@@ -246,13 +257,17 @@ extension PCKRevisionRecord {
246257
init(record: OCKRevisionRecord,
247258
remoteClockUUID: UUID,
248259
remoteClock: PCKClock,
249-
remoteClockValue: Int) throws {
260+
remoteClockValue: Int,
261+
storeClassesToSynchronize: [PCKStoreClass: any PCKVersionable.Type]? = nil,
262+
customClassesToSynchronize: [String: any PCKVersionable.Type]? = nil) throws {
250263
self.objectId = UUID().uuidString
251264
self.ACL = PCKUtility.getDefaultACL()
252265
self.clockUUID = remoteClockUUID
253266
self.logicalClock = remoteClockValue
254267
self.clock = remoteClock
255268
self.knowledgeVector = record.knowledgeVector
269+
self.storeClassesToSynchronize = storeClassesToSynchronize
270+
self.customClassesToSynchronize = customClassesToSynchronize
256271
self.entities = try record.entities.compactMap { entity in
257272
var parseEntity = try entity.parseEntity().value
258273
parseEntity.logicalClock = remoteClockValue // Stamp Entity

Sources/ParseCareKit/Models/PCKStoreClass.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import os.log
1313
// swiftlint:disable line_length
1414

1515
/// Types of ParseCareKit classes.
16-
public enum PCKStoreClass: String, CaseIterable {
16+
public enum PCKStoreClass: String, Equatable, CaseIterable {
1717
/// The ParseCareKit equivalent of `OCKPatient`.
1818
case patient
1919
/// The ParseCareKit equivalent of `OCKCarePlan`.

Sources/ParseCareKit/ParseRemote.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ParseRemote: OCKRemoteSynchronizable {
3636
public var uuid: UUID!
3737

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

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

0 commit comments

Comments
 (0)