Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Fix percentage staleness on the watch
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamazz committed Nov 18, 2015
1 parent 0f3c614 commit 518b60a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Gulps WatchKit Extension/WatchEntryHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ class WatchEntryHelper {
userDefaults.synchronize()
}

/**
Application Context sent by the watch
- Returns: [String: Double]
*/
func applicationContext() -> [String: Double] {
let quantity = userDefaults.doubleForKey(Constants.WatchContext.Current.key())
return [
Constants.Gulp.Goal.key(): userDefaults.doubleForKey(Constants.Gulp.Goal.key()),
Constants.WatchContext.Current.key(): quantity,
Constants.WatchContext.Current.key(): quantity(),
Constants.Gulp.Small.key(): userDefaults.doubleForKey(Constants.Gulp.Small.key()),
Constants.Gulp.Big.key(): userDefaults.doubleForKey(Constants.Gulp.Big.key())]
}

/**
Returns the current quantity
It also checks if the data is stale, resetting the quantity if needed
- Returns: Int? the current percentage
- Returns: Double the current quantity
*/
func quantity() -> Double {
let quantity = userDefaults.doubleForKey(Constants.WatchContext.Current.key())
Expand Down

0 comments on commit 518b60a

Please sign in to comment.