Skip to content

Commit

Permalink
Fixed to determine the latest value in the cached list of values
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermanns committed Jan 21, 2018
1 parent cc71554 commit d08849b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nightguard WatchKit App/Base.lproj/Interface.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<items>
<group width="1" height="50" alignment="left" id="1AH-d7-hZo">
<items>
<label width="80" height="37" alignment="left" text="---" textAlignment="center" minimumScaleFactor="0.5" id="vdn-99-EwA">
<label width="80" height="45" alignment="left" text="---" textAlignment="center" baselineAdjustment="alignCenters" minimumScaleFactor="0.40000000000000002" id="vdn-99-EwA">
<fontDescription key="font" type="system" pointSize="46"/>
<variation key="device=watch38mm" width="60">
<fontDescription key="font" type="system" pointSize="38"/>
Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit Extension/ExtensionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate, URLSessionDelegate {
case _ as WKApplicationRefreshBackgroundTask:
// this task is completed below, our app will then suspend while the download session runs
print("WKApplicationRefreshBackgroundTask received, start URL session")
let _ = NightscoutCacheService.singleton.loadCurrentNightscoutDataInBackground()
//let _ = NightscoutCacheService.singleton.loadCurrentNightscoutDataInBackground()
task.setTaskCompleted()
case let sessionTask as WKURLSessionRefreshBackgroundTask:

Expand Down
2 changes: 1 addition & 1 deletion nightguard WatchKit Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
<key>CLKComplicationPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
<key>CLKComplicationSupportedFamilies</key>
Expand Down
4 changes: 4 additions & 0 deletions nightguard WatchKit Extension/NightscoutDataRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class NightscoutDataRepository {
defaults?.removeObject(forKey: Constants.todaysBgData)
defaults?.removeObject(forKey: Constants.yesterdaysBgData)
defaults?.removeObject(forKey: Constants.yesterdaysDayOfTheYear)
// this shouldn't be necessary anymore - remove it later
defaults?.synchronize()
}

func storeCurrentNightscoutData(_ bgData : NightscoutData) {
Expand Down Expand Up @@ -84,6 +86,8 @@ class NightscoutDataRepository {

fileprivate func storeBgData(keyName : String, _ bgData : [BloodSugar]) {

print("Storing \(bgData.count) using key \(keyName)")

let defaults = UserDefaults(suiteName: AppConstants.APP_GROUP_ID)
defaults!.set(NSKeyedArchiver.archivedData(withRootObject: bgData), forKey: keyName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@
value = "bloodValues[index-2].value">
</PersistentString>
<PersistentString
value = "bloodValues[index-1].value">
value = "deltaAmount">
</PersistentString>
<PersistentString
value = "deltaAmount">
value = "bloodValues[index-1].value">
</PersistentString>
</PersistentStrings>
</ContextState>
Expand Down Expand Up @@ -340,6 +340,14 @@
<ContextState
contextName = "NightscoutCacheService.yesterdaysValuesAreOutdated():NightscoutCacheService.swift">
</ContextState>
<ContextState
contextName = "static UserDefaultsRepository.readMaximumBloodGlucoseDisplayed():UserDefaultsRepository.swift">
<PersistentStrings>
<PersistentString
value = "defaults.float(forKey: &quot;maximumBloodGlucoseDisplayed&quot;)">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "ComplicationController.(getCurrentTimelineEntryForComplication(CLKComplication, withHandler : (CLKComplicationTimelineEntry?) -&gt; ()) -&gt; ()).(closure #1):ComplicationController.swift">
<PersistentStrings>
Expand Down
2 changes: 1 addition & 1 deletion nightguard/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
1 change: 0 additions & 1 deletion nightguard/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ class MainViewController: UIViewController {
present(alertController, animated: true, completion: nil)

UserDefaults.standard.set(true, forKey: "screenlockMessageShowed")
UserDefaults.standard.synchronize()
}
}

Expand Down
2 changes: 1 addition & 1 deletion nightguard/NightscoutService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class NightscoutService {
return Date.init(timeIntervalSince1970: 0)
}

return Date.init(timeIntervalSince1970: oldValues.first!.timestamp / 1000)
return Date.init(timeIntervalSince1970: oldValues.last!.timestamp / 1000)
}

func readDay(_ nrOfDaysAgo : Int, callbackHandler : @escaping (_ nrOfDay : Int, [BloodSugar]) -> Void) {
Expand Down
2 changes: 1 addition & 1 deletion nightguardTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion nightguardUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
</dict>
</plist>

0 comments on commit d08849b

Please sign in to comment.