Skip to content

Commit

Permalink
fix: Prevent app crash when nu insulin type
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiaanv committed Oct 3, 2024
1 parent 5637201 commit 7aa4be2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,12 @@ extension DanaKitPumpManager: PumpManager {
return
}

guard let insulinType = self.state.insulinType else {
self.log.error("Insulin type is nil...")
completion(.configuration(DanaKitPumpManagerError.unknown("Missing insulin type")))
return
}

delegateQueue.async {
let duration = self.estimatedDuration(toBolus: units)
self.log.info("Enact bolus, units: \(units)U, duration: \(duration)sec")
Expand Down Expand Up @@ -584,7 +590,7 @@ extension DanaKitPumpManager: PumpManager {
self.state.lastStatusPumpDateTime = (await self.fetchPumpTime()) ?? Date.now
self.state.lastStatusDate = Date.now

self.doseEntry = UnfinalizedDose(units: units, duration: duration, activationType: activationType, insulinType: self.state.insulinType!)
self.doseEntry = UnfinalizedDose(units: units, duration: duration, activationType: activationType, insulinType: insulinType)
self.doseReporter = DanaKitDoseProgressReporter(total: units)
self.state.bolusState = .inProgress
self.notifyStateDidChange()
Expand Down

0 comments on commit 7aa4be2

Please sign in to comment.