Skip to content

Commit b05f27c

Browse files
authored
Bug fix: carb dots overlapping SMB dots on the chart (#650)
- Restores pre-PR #305 behavior; no other dot positioning changes - Carb dots entered alongside an SMB were rendering at the same Y position as the SMB triangle, visually overlapping - The carb-vs-bolus collision logic was supposed to lift the carb dot above the bolus to BG+70, but only checked for Boluses (not SMB) - Regression comes from PR #305 (SMB display differentiated from boluses), which split SMBs into their own smbData array. - After the split, findNearestBolusbyTime in processNSCarbs no longer saw SMBs as "nearby treatments," so carb-near-SMB fell through to the default BG+20 offset: the same Y as the SMB itself. - processNSCarbs now also looks up smbData. - A carb within 300s of either a bolus OR SMB lifts to BG+70; otherwise BG+20.
1 parent 76a6aa4 commit b05f27c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • LoopFollow/Controllers/Nightscout/Treatments

LoopFollow/Controllers/Nightscout/Treatments/Carbs.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extension MainViewController {
1010
carbData.removeAll()
1111
var lastFoundIndex = 0
1212
var lastFoundBolus = 0
13+
var lastFoundSmb = 0
1314

1415
for currentEntry in entries.reversed() {
1516
var carbDate: String
@@ -35,7 +36,10 @@ extension MainViewController {
3536
let bolusTime = findNearestBolusbyTime(timeWithin: 300, needle: dateTimeStamp, haystack: bolusData, startingIndex: lastFoundBolus)
3637
lastFoundBolus = bolusTime.foundIndex
3738

38-
offset = bolusTime.offset ? 70 : 20
39+
let smbTime = findNearestBolusbyTime(timeWithin: 300, needle: dateTimeStamp, haystack: smbData, startingIndex: lastFoundSmb)
40+
lastFoundSmb = smbTime.foundIndex
41+
42+
offset = (bolusTime.offset || smbTime.offset) ? 70 : 20
3943
}
4044

4145
if dateTimeStamp < (dateTimeUtils.getNowTimeIntervalUTC() + (3600 * Storage.shared.predictionToLoad.value)) {

0 commit comments

Comments
 (0)