Skip to content

Commit

Permalink
feat(ios): also log error;
Browse files Browse the repository at this point in the history
  • Loading branch information
mat1th committed Jun 6, 2024
1 parent 141c31c commit 1afe1f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 0 additions & 1 deletion Sources/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ extension AppEnvironment {

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

let sceneManager = SceneManager()
private let lifecycleManager = LifecycleManager()
let notificationManager = NotificationManager()
Expand Down
29 changes: 17 additions & 12 deletions Sources/App/WebView/IncomingURLHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ class IncomingURLHandler {
return false
}

if let presenting = windowController.presentedViewController,
presenting is SFSafariViewController {
if
let presenting = windowController.presentedViewController,
presenting is SFSafariViewController {
// Dismiss my.* controller if it's on top - we don't get any other indication
presenting.dismiss(animated: true, completion: { [windowController] in
windowController?.openSelectingServer(
Expand Down Expand Up @@ -104,8 +105,8 @@ class IncomingURLHandler {
pipeline: pipeline?.identifier ?? "",
autoStartRecording: autoStartRecording
)
case .rejected:
Current.Log.error("Failed to obtain webview to open Assist In App")
case let .rejected(error):
Current.Log.error("Failed to obtain webview to open Assist In App: \(error.localizedDescription)")
}
}

Expand Down Expand Up @@ -137,8 +138,9 @@ class IncomingURLHandler {
if let url = userActivity.webpageURL, url.host?.lowercased() == "my.home-assistant.io" {
return showMy(for: url)
} else if let interaction = userActivity.interaction {
if let intent = interaction.intent as? OpenPageIntent,
let panel = intent.page, let path = panel.identifier {
if
let intent = interaction.intent as? OpenPageIntent,
let panel = intent.page, let path = panel.identifier {
Current.Log.info("launching from shortcuts with panel \(panel)")

let urlString = "/" + path
Expand Down Expand Up @@ -177,8 +179,9 @@ class IncomingURLHandler {
})
}.asVoid()
} else {
if let action = Current.realm().object(ofType: Action.self, forPrimaryKey: shortcutItem.type),
let server = Current.servers.server(for: action) {
if
let action = Current.realm().object(ofType: Action.self, forPrimaryKey: shortcutItem.type),
let server = Current.servers.server(for: action) {
Current.sceneManager.showFullScreenConfirm(
icon: MaterialDesignIcons(named: action.IconName),
text: action.Text,
Expand Down Expand Up @@ -517,8 +520,9 @@ extension IncomingURLHandler {
}

let source: HomeAssistantAPI.ActionSource = {
if let sourceString = serviceData["source"],
let source = HomeAssistantAPI.ActionSource(rawValue: sourceString) {
if
let sourceString = serviceData["source"],
let source = HomeAssistantAPI.ActionSource(rawValue: sourceString) {
return source
} else {
return .URLHandler
Expand All @@ -527,8 +531,9 @@ extension IncomingURLHandler {

let actionID = url.pathComponents[1]

guard let action = Current.realm().object(ofType: Action.self, forPrimaryKey: actionID),
let server = Current.servers.server(for: action) else {
guard
let action = Current.realm().object(ofType: Action.self, forPrimaryKey: actionID),
let server = Current.servers.server(for: action) else {
Current.sceneManager.showFullScreenConfirm(
icon: .alertCircleIcon,
text: L10n.UrlHandler.Error.actionNotFound,
Expand Down

0 comments on commit 1afe1f4

Please sign in to comment.