|
@@ -204,13 +204,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
|
|
|
let sampleDates = samples.map(\.startDate)
|
|
let sampleDates = samples.map(\.startDate)
|
|
|
let samplesToSave = carbsWithId
|
|
let samplesToSave = carbsWithId
|
|
|
.filter { !sampleIDs.contains($0.id ?? "") } // id existing in AH
|
|
.filter { !sampleIDs.contains($0.id ?? "") } // id existing in AH
|
|
|
- .filter { !sampleDates.contains($0.actualDate ?? $0.createdAt) } // not id but exactly the same datetime
|
|
|
|
|
|
|
+ .filter { !sampleDates.contains($0.createdAt) } // not id but exactly the same datetime
|
|
|
.map {
|
|
.map {
|
|
|
HKQuantitySample(
|
|
HKQuantitySample(
|
|
|
type: sampleType,
|
|
type: sampleType,
|
|
|
quantity: HKQuantity(unit: .gram(), doubleValue: Double($0.carbs)),
|
|
quantity: HKQuantity(unit: .gram(), doubleValue: Double($0.carbs)),
|
|
|
- start: $0.actualDate ?? $0.createdAt,
|
|
|
|
|
- end: $0.actualDate ?? $0.createdAt,
|
|
|
|
|
|
|
+ start: $0.createdAt,
|
|
|
|
|
+ end: $0.createdAt,
|
|
|
metadata: [
|
|
metadata: [
|
|
|
HKMetadataKeySyncIdentifier: $0.id ?? "_id",
|
|
HKMetadataKeySyncIdentifier: $0.id ?? "_id",
|
|
|
HKMetadataKeySyncVersion: 1,
|
|
HKMetadataKeySyncVersion: 1,
|