mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-16 10:21:16 -06:00
<!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> As the [minimum watchOS is 8](https://github.com/home-assistant/iOS/pull/2609) and [minimum iOS 15](https://github.com/home-assistant/iOS/pull/2469), this PR removes redundant `#available` checks. Co-authored-by: Bruno Pantaleão Gonçalves <bruno.ing879@gmail.com>
30 lines
1.0 KiB
Swift
30 lines
1.0 KiB
Swift
import Foundation
|
|
import Intents
|
|
import PromiseKit
|
|
|
|
class FocusStatusIntentHandler: NSObject, INShareFocusStatusIntentHandling {
|
|
func handle(intent: INShareFocusStatusIntent, completion: @escaping (INShareFocusStatusIntentResponse) -> Void) {
|
|
let currentState = intent.focusStatus
|
|
Current.focusStatus.update(fromReceived: currentState)
|
|
Current.Log.info("starting, status from intent is \(String(describing: currentState)) from \(intent)")
|
|
|
|
let limitedTo: [SensorProvider.Type]?
|
|
|
|
if Current.isCatalyst {
|
|
limitedTo = [FocusSensor.self]
|
|
} else {
|
|
limitedTo = nil
|
|
}
|
|
|
|
when(fulfilled: Current.apis.map {
|
|
$0.UpdateSensors(trigger: .Siri, limitedTo: limitedTo)
|
|
}).done {
|
|
Current.Log.info("finished successfully")
|
|
completion(.init(code: .success, userActivity: nil))
|
|
}.catch { error in
|
|
Current.Log.error("failed: \(error)")
|
|
completion(.init(code: .failure, userActivity: nil))
|
|
}
|
|
}
|
|
}
|