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

Rework History Sheet #140

Merged
merged 8 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions FreeAPS/Sources/Models/NightscoutTreatment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Foundation
func determineBolusEventType(for event: PumpHistoryEvent) -> EventType {
if event.isExternalInsulin ?? false {
return .nsExternalInsulin
} else if event.isSMB ?? false {
return .smb
}
return event.type
}
Expand Down
1 change: 1 addition & 0 deletions FreeAPS/Sources/Models/PumpHistoryEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct PumpHistoryEvent: JSON, Equatable {

enum EventType: String, JSON {
case bolus = "Bolus"
case smb = "SMB"
case mealBolus = "Meal Bolus"
case correctionBolus = "Correction Bolus"
case snackBolus = "Snack Bolus"
Expand Down
2 changes: 0 additions & 2 deletions FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ enum DataTable {

if isExternal ?? false {
bolusText += " " + NSLocalizedString("External", comment: "External Insulin")
} else if isSMB ?? false {
bolusText += " " + NSLocalizedString("SMB", comment: "SMB")
}

return numberFormatter
Expand Down
12 changes: 6 additions & 6 deletions FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension DataTable {
@Published var mode: Mode = .treatments
@Published var treatments: [Treatment] = []
@Published var glucose: [Glucose] = []
@Published var manualGlcuose: Decimal = 0
@Published var manualGlucose: Decimal = 0
@Published var maxBolus: Decimal = 0
@Published var externalInsulinAmount: Decimal = 0
@Published var externalInsulinDate = Date()
Expand Down Expand Up @@ -156,8 +156,8 @@ extension DataTable {
.store(in: &lifetime)
}

func deleteGlucose(at index: Int) {
let id = glucose[index].id
func deleteGlucose(_ glucose: Glucose) {
let id = glucose.id
provider.deleteGlucose(id: id)

let fetchRequest: NSFetchRequest<NSFetchRequestResult>
Expand All @@ -181,8 +181,8 @@ extension DataTable {
// try? coredataContext.save()
}

func addManualGlucose() {
let glucose = units == .mmolL ? manualGlcuose.asMgdL : manualGlcuose
func logManualGlucose() {
let glucose = units == .mmolL ? manualGlucose.asMgdL : manualGlucose
let now = Date()
let id = UUID().uuidString

Expand All @@ -201,7 +201,7 @@ extension DataTable {
debug(.default, "Manual Glucose saved to glucose.json")
}

func addExternalInsulin() {
func logExternalInsulin() {
guard externalInsulinAmount > 0 else {
showModal(for: nil)
return
Expand Down
Loading