Skip to content

Commit

Permalink
Merge pull request #140 from nightscout/swipe-to-delete
Browse files Browse the repository at this point in the history
Rework History Sheet
  • Loading branch information
MikePlante1 authored May 12, 2024
2 parents b851a5e + 67ddedb commit 74fd65f
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 152 deletions.
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

0 comments on commit 74fd65f

Please sign in to comment.