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:
Zac West
2021-09-18 20:34:15 -07:00
committed by GitHub
parent bb53bdd5e5
commit 293fae54cf
4 changed files with 42 additions and 6 deletions

View File

@@ -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)
}