Files
openclaw/apps/ios/WatchApp/Sources/WatchDeferredPayloadOrdering.swift
Peter Steinberger 54f45a950b feat(watchos): connect directly to Gateway as a node (#102893)
* feat(watchos): add direct gateway node

* docs: refresh watch node docs map

* chore: leave release notes to release workflow

* chore(ios): refresh native localization inventory

* fix(watchos): keep direct node policy bounded
2026-07-09 15:53:02 +01:00

27 lines
1013 B
Swift

enum WatchDeferredPayloadOrdering {
static func isExpired(expiresAtMs: Int64?, nowMs: Int64) -> Bool {
expiresAtMs.map { $0 <= nowMs } == true
}
static func isNewerThanSnapshot(payloadSentAtMs: Int64?, snapshotSentAtMs: Int64?) -> Bool {
guard let payloadSentAtMs, let snapshotSentAtMs else { return true }
return payloadSentAtMs > snapshotSentAtMs
}
static func isAtOrBeforeSnapshot(payloadSentAtMs: Int64?, snapshotSentAtMs: Int64?) -> Bool {
guard let snapshotSentAtMs else { return false }
return payloadSentAtMs.map { $0 <= snapshotSentAtMs } ?? true
}
static func indicesOldestFirst(for timestamps: [Int64?]) -> [Int] {
timestamps.indices.sorted { lhs, rhs in
let lhsTimestamp = timestamps[lhs] ?? .min
let rhsTimestamp = timestamps[rhs] ?? .min
if lhsTimestamp != rhsTimestamp {
return lhsTimestamp < rhsTimestamp
}
return lhs < rhs
}
}
}