Преглед изворни кода

Remove `actualDate` as introduced in https://github.com/nightscout/Open-iAPS/pull/22

Proposed in conjunction with https://github.com/nightscout/open-iaps-oref/pull/14
bjornoleh пре 2 година
родитељ
комит
6fb3691036

+ 1 - 1
FreeAPS/Sources/APS/Storage/CarbsStorage.swift

@@ -81,7 +81,7 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
                     } else { useDate = useDate.addingTimeInterval(interval.minutes.timeInterval) }
 
                     let eachCarbEntry = CarbsEntry(
-                        id: UUID().uuidString, createdAt: entries.last?.createdAt ?? Date(), actualDate: useDate,
+                        id: UUID().uuidString, createdAt: entries.last?.createdAt ?? Date(),
                         carbs: equivalent, fat: 0, protein: 0, note: nil,
                         enteredBy: CarbsEntry.manual, isFPU: true,
                         fpuID: fpuID

+ 0 - 2
FreeAPS/Sources/Models/CarbsEntry.swift

@@ -3,7 +3,6 @@ import Foundation
 struct CarbsEntry: JSON, Equatable, Hashable {
     let id: String?
     let createdAt: Date
-    let actualDate: Date?
     let carbs: Decimal
     let fat: Decimal?
     let protein: Decimal?
@@ -28,7 +27,6 @@ extension CarbsEntry {
     private enum CodingKeys: String, CodingKey {
         case id = "_id"
         case createdAt = "created_at"
-        case actualDate
         case carbs
         case fat
         case protein

+ 0 - 1
FreeAPS/Sources/Modules/AddCarbs/AddCarbsStateModel.swift

@@ -38,7 +38,6 @@ extension AddCarbs {
                 [CarbsEntry(
                     id: UUID().uuidString,
                     createdAt: Date.now,
-                    actualDate: date,
                     carbs: carbs,
                     fat: fat,
                     protein: protein,

+ 3 - 3
FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift

@@ -204,13 +204,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
             let sampleDates = samples.map(\.startDate)
             let samplesToSave = carbsWithId
                 .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 {
                     HKQuantitySample(
                         type: sampleType,
                         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: [
                             HKMetadataKeySyncIdentifier: $0.id ?? "_id",
                             HKMetadataKeySyncVersion: 1,

+ 0 - 1
FreeAPS/Sources/Services/WatchManager/WatchManager.swift

@@ -274,7 +274,6 @@ extension BaseWatchManager: WCSessionDelegate {
                 [CarbsEntry(
                     id: UUID().uuidString,
                     createdAt: Date.now,
-                    actualDate: Date.now,
                     carbs: Decimal(carbs),
                     fat: Decimal(fat),
                     protein: Decimal(protein), note: nil,