mirror of
https://github.com/home-assistant/iOS.git
synced 2026-05-02 15:24:14 -05:00
Fix focus sensor updating in iOS 15 RC (#1842)
## Summary Fixes the insta-updating of the focus sensor on iOS 15. ## Any other notes `INFocusStatusCenter.default.focusStatus` always returns isFocused=false in the extension, but the intent provides the correct focus status for each update -- so we need to cache this value in the extension, and not trust the focus center state.
This commit is contained in:
@@ -4,6 +4,7 @@ import PromiseKit
|
||||
final class FocusSensor: SensorProvider {
|
||||
public enum FocusError: Error, Equatable {
|
||||
case unauthorized
|
||||
case unavailable
|
||||
}
|
||||
|
||||
let request: SensorProviderRequest
|
||||
@@ -12,6 +13,10 @@ final class FocusSensor: SensorProvider {
|
||||
}
|
||||
|
||||
func sensors() -> Promise<[WebhookSensor]> {
|
||||
guard Current.focusStatus.isAvailable() else {
|
||||
return .init(error: FocusError.unavailable)
|
||||
}
|
||||
|
||||
guard Current.focusStatus.authorizationStatus() == .authorized else {
|
||||
return .init(error: FocusError.unauthorized)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user