Adjust rest time from the watch with the same 1-second stepper
A gear on the watch root opens a small Settings sheet whose stepper edits the shared restSeconds default (10-180s, 1s steps). Edits ride a new settingsUpdate message to the phone - debounced per stepper burst, falling back to transferUserInfo when unreachable - which clamps the value, writes the shared default, and re-echoes it to every device through the application context. While an edit is pending on the watch, an in-flight context's stale rest value is skipped so it can't yank the stepper back mid-edit.
This commit is contained in:
@@ -21,6 +21,7 @@ enum WCPayload {
|
||||
|
||||
static let workoutUpdateType = "workoutUpdate" // watch → phone (one workout)
|
||||
static let requestSyncType = "requestSync" // watch → phone (please push state)
|
||||
static let settingsUpdateType = "settingsUpdate" // watch → phone (a setting changed on the watch)
|
||||
static let liveProgressType = "liveProgress" // watch → phone (ephemeral mirror frame)
|
||||
static let liveEndedType = "liveEnded" // watch → phone (stop mirroring a run)
|
||||
static let liveHeartRateType = "liveHeartRate" // watch → phone (ephemeral HR sample)
|
||||
@@ -82,6 +83,16 @@ enum WCPayload {
|
||||
|
||||
static func requestSyncMessage() -> [String: Any] { [typeKey: requestSyncType] }
|
||||
|
||||
// MARK: - Watch → Phone (a setting changed on the watch)
|
||||
|
||||
/// The watch's settings edits ride to the phone, which owns the durable value and
|
||||
/// echoes it back to every device through the application context. Carries only the
|
||||
/// settings the watch can edit (just rest time today); reuses the context's key, so
|
||||
/// `decodeRestSeconds` reads both.
|
||||
static func encodeSettingsUpdate(restSeconds: Int) -> [String: Any] {
|
||||
[typeKey: settingsUpdateType, restSecondsKey: restSeconds]
|
||||
}
|
||||
|
||||
// MARK: - Watch → Phone (ephemeral live-run mirror)
|
||||
|
||||
/// Anchor `Date`s ride as native plist values (not JSON), so they keep sub-second
|
||||
|
||||
Reference in New Issue
Block a user