Skip to content

Commit ad522c9

Browse files
committed
Merge pull request #2 from loudnate/read-reservoir
Read reservoir before bolusing
2 parents a8e2e6c + 40bff05 commit ad522c9

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ github "loudnate/LoopKit" ~> 0.3
22
github "loudnate/xDripG5" ~> 0.4
33
github "loudnate/SwiftCharts" "loudnate/naterade"
44
github "mddub/dexcom-share-client-swift" ~> 0.1
5-
github "ps2/rileylink_ios" ~> 0.3
5+
github "ps2/rileylink_ios" "dev"
66
github "mpurland/Amplitude-iOS" "framework"

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ github "loudnate/Crypto" "e0ef5b498f2c373d676135dabf5d1803b8558509"
33
github "loudnate/LoopKit" "v0.3.2"
44
github "loudnate/SwiftCharts" "448b80f4025bbf592a4d8ca9d079e9684bc0b64b"
55
github "mddub/dexcom-share-client-swift" "v0.1.0"
6-
github "ps2/rileylink_ios" "v0.3.0"
6+
github "ps2/rileylink_ios" "4305a83f897c19bd343c6b4f6fcdaaba0985ea64"
77
github "loudnate/xDripG5" "0.4.1"

Loop/Managers/LoopDataManager.swift

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,30 @@ class LoopDataManager {
516516
return
517517
}
518518

519-
ops.setNormalBolus(units) { (error) in
520-
if let error = error {
521-
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
519+
ops.readRemainingInsulin { (result) in
520+
switch result {
521+
case .Success(let unitVolume):
522+
self.deviceDataManager.doseStore.addReservoirValue(unitVolume, atDate: NSDate()) { (_, _, error) in
523+
if let error = error {
524+
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
525+
resultsHandler(success: false, error: .CommunicationError)
526+
} else {
527+
ops.setNormalBolus(units) { (error) in
528+
if let error = error {
529+
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
530+
resultsHandler(success: false, error: .CommunicationError)
531+
} else {
532+
self.lastBolus = (units: units, date: NSDate())
533+
resultsHandler(success: true, error: nil)
534+
}
522535

536+
self.notify()
537+
}
538+
}
539+
}
540+
case .Failure(let error):
541+
self.deviceDataManager.logger?.addError(error, fromSource: "Bolus")
523542
resultsHandler(success: false, error: .CommunicationError)
524-
} else {
525-
self.lastBolus = (units: units, date: NSDate())
526-
527-
resultsHandler(success: true, error: nil)
528543
}
529544
}
530545
}

0 commit comments

Comments
 (0)