|
@@ -78,21 +78,23 @@ extension MainViewController {
|
|
|
// If Dex data is old, load from NS instead
|
|
// If Dex data is old, load from NS instead
|
|
|
let latestDate = data[0].date
|
|
let latestDate = data[0].date
|
|
|
let now = dateTimeUtils.getNowTimeIntervalUTC()
|
|
let now = dateTimeUtils.getNowTimeIntervalUTC()
|
|
|
- if (latestDate + 330) < now {
|
|
|
|
|
|
|
+ if (latestDate + 330) < now && UserDefaultsRepository.url.value != "" {
|
|
|
self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord)
|
|
self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord)
|
|
|
print("dex didn't load, triggered NS attempt")
|
|
print("dex didn't load, triggered NS attempt")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Dexcom only returns 24 hrs of data. If we need more, call NS.
|
|
// Dexcom only returns 24 hrs of data. If we need more, call NS.
|
|
|
- if graphHours > 24 && !onlyPullLastRecord {
|
|
|
|
|
|
|
+ if graphHours > 24 && !onlyPullLastRecord && UserDefaultsRepository.url.value != "" {
|
|
|
self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord, dexData: data)
|
|
self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord, dexData: data)
|
|
|
} else {
|
|
} else {
|
|
|
self.ProcessDexBGData(data: data, onlyPullLastRecord: onlyPullLastRecord, sourceName: "Dexcom")
|
|
self.ProcessDexBGData(data: data, onlyPullLastRecord: onlyPullLastRecord, sourceName: "Dexcom")
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// If we get an error, immediately try to pull NS BG Data
|
|
// If we get an error, immediately try to pull NS BG Data
|
|
|
- self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord)
|
|
|
|
|
|
|
+ if UserDefaultsRepository.url.value != "" {
|
|
|
|
|
+ self.webLoadNSBGData(onlyPullLastRecord: onlyPullLastRecord)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if globalVariables.dexVerifiedAlert < dateTimeUtils.getNowTimeIntervalUTC() + 300 {
|
|
if globalVariables.dexVerifiedAlert < dateTimeUtils.getNowTimeIntervalUTC() + 300 {
|
|
|
globalVariables.dexVerifiedAlert = dateTimeUtils.getNowTimeIntervalUTC()
|
|
globalVariables.dexVerifiedAlert = dateTimeUtils.getNowTimeIntervalUTC()
|
|
@@ -107,6 +109,12 @@ extension MainViewController {
|
|
|
// NS BG Data Web call
|
|
// NS BG Data Web call
|
|
|
func webLoadNSBGData(onlyPullLastRecord: Bool = false, dexData: [ShareGlucoseData] = []) {
|
|
func webLoadNSBGData(onlyPullLastRecord: Bool = false, dexData: [ShareGlucoseData] = []) {
|
|
|
if UserDefaultsRepository.debugLog.value { self.writeDebugLog(value: "Download: BG") }
|
|
if UserDefaultsRepository.debugLog.value { self.writeDebugLog(value: "Download: BG") }
|
|
|
|
|
+
|
|
|
|
|
+ // This kicks it out in the instance where dexcom fails but they aren't using NS &&
|
|
|
|
|
+ if UserDefaultsRepository.url.value == "" {
|
|
|
|
|
+ self.startBGTimer(time: 10)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
let graphHours = 24 * UserDefaultsRepository.downloadDays.value
|
|
let graphHours = 24 * UserDefaultsRepository.downloadDays.value
|
|
|
// Set the count= in the url either to pull day(s) of data or only the last record
|
|
// Set the count= in the url either to pull day(s) of data or only the last record
|
|
|
var points = "1"
|
|
var points = "1"
|