Skip to content

Commit 34e90ad

Browse files
Modify condition for showing the "Loading BG data" message
1 parent 205afca commit 34e90ad

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

nightguard WatchKit Extension/InterfaceController.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,15 @@ class InterfaceController: WKInterfaceController, WKCrownDelegate {
371371

372372
func loadAndPaintChartData(forceRepaint : Bool) {
373373

374+
// show a message if the today & yesterday data is missing, we're gonna load them now (will show on first install and when URI changes)
375+
if UserDefaultsRepository.baseUri.exists && NightscoutCacheService.singleton.isEmpty && NightscoutDataRepository.singleton.isEmpty {
376+
showMessage("Loading BG data...")
377+
}
378+
374379
let newCachedTodaysBgValues: [BloodSugar]
375380
if NightscoutCacheService.singleton.hasTodaysBgDataPendingRequests {
376381
newCachedTodaysBgValues = NightscoutDataRepository.singleton.loadTodaysBgData()
377382
} else {
378-
379-
// show a message if the today & yesterday data is missing, we're gonna load them now (will show on first install and when URI changes)
380-
if UserDefaultsRepository.baseUri.exists && NightscoutCacheService.singleton.isEmpty {
381-
showMessage("Loading BG data...")
382-
}
383-
384383
newCachedTodaysBgValues = NightscoutCacheService.singleton.loadTodaysData { [unowned self] result in
385384
guard let result = result else { return }
386385

nightguard WatchKit Extension/NightscoutDataRepository.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class NightscoutDataRepository {
2020
static let yesterdaysDayOfTheYear = "yesterdaysDayOfTheYear"
2121
}
2222

23+
var isEmpty: Bool {
24+
return loadYesterdaysBgData().isEmpty && loadTodaysBgData().isEmpty
25+
}
26+
2327
func clearAll() {
2428
let defaults = UserDefaults(suiteName: AppConstants.APP_GROUP_ID)
2529
defaults?.removeObject(forKey: Constants.currentBgData)

0 commit comments

Comments
 (0)