Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport HealthKit fix to earlier version #22

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FreeAPS/Sources/APS/Storage/CarbsStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
} else { useDate = useDate.addingTimeInterval(interval.minutes.timeInterval) }

let eachCarbEntry = CarbsEntry(
id: UUID().uuidString, createdAt: useDate, carbs: equivalent, fat: 0, protein: 0, note: nil,
id: UUID().uuidString, createdAt: entries.last?.createdAt ?? Date(), actualDate: useDate,
carbs: equivalent, fat: 0, protein: 0, note: nil,
enteredBy: CarbsEntry.manual, isFPU: true,
fpuID: fpuID
)
Expand Down
2 changes: 2 additions & 0 deletions FreeAPS/Sources/Models/CarbsEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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?
Expand All @@ -27,6 +28,7 @@ extension CarbsEntry {
private enum CodingKeys: String, CodingKey {
case id = "_id"
case createdAt = "created_at"
case actualDate
case carbs
case fat
case protein
Expand Down
3 changes: 2 additions & 1 deletion FreeAPS/Sources/Modules/AddCarbs/AddCarbsStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ extension AddCarbs {
carbsStorage.storeCarbs(
[CarbsEntry(
id: UUID().uuidString,
createdAt: date,
createdAt: Date.now,
actualDate: date,
carbs: carbs,
fat: fat,
protein: protein,
Expand Down
Loading