Skip to content
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
7 changes: 5 additions & 2 deletions LoopFollow/Controllers/Nightscout/BGData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ extension MainViewController {
self.startBGTimer(time: 300 - secondsAgo + Double(UserDefaultsRepository.bgUpdateDelay.value))
let timerVal = 310 - secondsAgo
print("##### started 5:10 bg timer: \(timerVal)")
self.updateBadge(val: data[0].sgv)
self.evaluateSpeakConditions(currentValue: data[0].sgv, previousValue: data[1].sgv)
if data.count > 1 {
self.evaluateSpeakConditions(currentValue: data[0].sgv, previousValue: data[1].sgv)
}
}
}

Expand Down Expand Up @@ -276,8 +277,10 @@ extension MainViewController {
attributeString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: attributeString.length))
if deltaTime >= 12 { // Data is stale
attributeString.addAttribute(.strikethroughColor, value: UIColor.systemRed, range: NSRange(location: 0, length: attributeString.length))
self.updateBadge(val: 0)
} else { // Data is fresh
attributeString.addAttribute(.strikethroughColor, value: UIColor.clear, range: NSRange(location: 0, length: attributeString.length))
self.updateBadge(val: latestBG)
}
self.BGText.attributedText = attributeString

Expand Down
6 changes: 2 additions & 4 deletions LoopFollow/ViewControllers/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,11 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
}

func updateBadge(val: Int) {
DispatchQueue.main.async {
if UserDefaultsRepository.appBadge.value {
let latestBG = String(val)
UIApplication.shared.applicationIconBadgeNumber = Int(bgUnits.removePeriodAndCommaForBadge(bgUnits.toDisplayUnits(latestBG))) ?? val
} else {
UIApplication.shared.applicationIconBadgeNumber = 0
}
} else {
UIApplication.shared.applicationIconBadgeNumber = 0
}
}

Expand Down