Skip to content

Commit

Permalink
Fix crash when signed out and issuing intent (#1278)
Browse files Browse the repository at this point in the history
These confirm blocks were firing an error case and then success case. They aren't needed necessary any more since we do the validation when resolving.

Fixes #1250.
  • Loading branch information
zacwest committed Nov 17, 2020
1 parent 1bd1b63 commit 0e01644
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 48 deletions.
10 changes: 0 additions & 10 deletions Sources/Extensions/Intents/CallService.swift
Expand Up @@ -66,16 +66,6 @@ class CallServiceIntentHandler: NSObject, CallServiceIntentHandling {
}
}

func confirm(intent: CallServiceIntent, completion: @escaping (CallServiceIntentResponse) -> Void) {
HomeAssistantAPI.authenticatedAPIPromise.catch { (error) in
Current.Log.error("Can't get a authenticated API \(error)")
completion(CallServiceIntentResponse(code: .failureConnectivity, userActivity: nil))
return
}

completion(CallServiceIntentResponse(code: .ready, userActivity: nil))
}

// swiftlint:disable:next function_body_length
func handle(intent: CallServiceIntent, completion: @escaping (CallServiceIntentResponse) -> Void) {
guard let api = HomeAssistantAPI.authenticatedAPI() else {
Expand Down
10 changes: 0 additions & 10 deletions Sources/Extensions/Intents/GetCameraImage.swift
Expand Up @@ -53,16 +53,6 @@ class GetCameraImageIntentHandler: NSObject, GetCameraImageIntentHandling {
}
}

func confirm(intent: GetCameraImageIntent, completion: @escaping (GetCameraImageIntentResponse) -> Void) {
HomeAssistantAPI.authenticatedAPIPromise.catch { (error) in
Current.Log.error("Can't get a authenticated API \(error)")
completion(GetCameraImageIntentResponse(code: .failureConnectivity, userActivity: nil))
return
}

completion(GetCameraImageIntentResponse(code: .ready, userActivity: nil))
}

func handle(intent: GetCameraImageIntent, completion: @escaping (GetCameraImageIntentResponse) -> Void) {
guard let api = HomeAssistantAPI.authenticatedAPI() else {
completion(GetCameraImageIntentResponse(code: .failureConnectivity, userActivity: nil))
Expand Down
10 changes: 0 additions & 10 deletions Sources/Extensions/Intents/RenderTemplate.swift
Expand Up @@ -23,16 +23,6 @@ class RenderTemplateIntentHandler: NSObject, RenderTemplateIntentHandling {
}
}

func confirm(intent: RenderTemplateIntent, completion: @escaping (RenderTemplateIntentResponse) -> Void) {
HomeAssistantAPI.authenticatedAPIPromise.catch { (error) in
Current.Log.error("Can't get a authenticated API \(error)")
completion(RenderTemplateIntentResponse(code: .failureConnectivity, userActivity: nil))
return
}

completion(RenderTemplateIntentResponse(code: .ready, userActivity: nil))
}

func handle(intent: RenderTemplateIntent, completion: @escaping (RenderTemplateIntentResponse) -> Void) {
guard let api = HomeAssistantAPI.authenticatedAPI() else {
completion(RenderTemplateIntentResponse(code: .failureConnectivity, userActivity: nil))
Expand Down
18 changes: 0 additions & 18 deletions Sources/Extensions/Intents/SendLocation.swift
Expand Up @@ -24,24 +24,6 @@ class SendLocationIntentHandler: NSObject, SendLocationIntentHandling {
}
}

func confirm(intent: SendLocationIntent, completion: @escaping (SendLocationIntentResponse) -> Void) {

HomeAssistantAPI.authenticatedAPIPromise.catch { (error) in
Current.Log.error("Can't get a authenticated API \(error)")
completion(SendLocationIntentResponse(code: .failureConnectivity, userActivity: nil))
return
}

guard intent.location != nil else {
let resp = SendLocationIntentResponse(code: .failure, userActivity: nil)
resp.error = "Location is not set"
completion(resp)
return
}

completion(SendLocationIntentResponse(code: .ready, userActivity: nil))
}

func handle(intent: SendLocationIntent, completion: @escaping (SendLocationIntentResponse) -> Void) {
Current.Log.verbose("Handling send location")

Expand Down

0 comments on commit 0e01644

Please sign in to comment.