diff --git a/Sources/App/Resources/en.lproj/Localizable.strings b/Sources/App/Resources/en.lproj/Localizable.strings index c2fea40b7..6b296857e 100644 --- a/Sources/App/Resources/en.lproj/Localizable.strings +++ b/Sources/App/Resources/en.lproj/Localizable.strings @@ -1054,4 +1054,6 @@ Home Assistant is free and open source home automation software with a focus on "widgets.sensors.description" = "Display state of sensors"; "widgets.sensors.not_configured" = "No Sensors Configured"; "widgets.sensors.title" = "Sensors"; -"yes_label" = "Yes"; \ No newline at end of file +"network.error.no_active_url.title" = "No URL available to load"; +"network.error.no_active_url.body" = "Open companion app settings and check your server settings, internal URL will only be used if local network is defined (SSID), if you are using VPN try setting your external URL as the same as internal URL."; +"yes_label" = "Yes"; diff --git a/Sources/App/WebView/WebViewController.swift b/Sources/App/WebView/WebViewController.swift index 0a2831622..a075ea26a 100644 --- a/Sources/App/WebView/WebViewController.swift +++ b/Sources/App/WebView/WebViewController.swift @@ -598,6 +598,29 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg sidebarGestureRecognizer.isEnabled = server.info.version >= .externalBusCommandSidebar } + private func showNoActiveURLError() { + Current.Log.info("Showing noActiveURLError") + var config = swiftMessagesConfig() + let view = MessageView.viewFromNib(layout: .messageView) + view.configureContent( + title: L10n.Network.Error.NoActiveUrl.title, + body: L10n.Network.Error.NoActiveUrl.body, + iconImage: nil, + iconText: nil, + buttonImage: MaterialDesignIcons.cogIcon.image( + ofSize: CGSize(width: 30, height: 30), + color: Asset.Colors.haPrimary.color + ), + buttonTitle: nil, + buttonTapHandler: { [weak self] _ in + self?.showSettingsViewController() + SwiftMessages.hide() + } + ) + + SwiftMessages.show(config: config, view: view) + } + @objc private func connectionInfoDidChange() { DispatchQueue.main.async { [self] in loadActiveURLIfNeeded() @@ -608,6 +631,7 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg @objc private func loadActiveURLIfNeeded() { guard let webviewURL = server.info.connection.webviewURL() else { Current.Log.info("not loading, no url") + showNoActiveURLError() return } @@ -645,6 +669,8 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg } else { webView.load(URLRequest(url: webviewURL)) } + } else { + showNoActiveURLError() } } diff --git a/Sources/Shared/Resources/Swiftgen/Strings.swift b/Sources/Shared/Resources/Swiftgen/Strings.swift index 7345dd6f2..9c720943a 100644 --- a/Sources/Shared/Resources/Swiftgen/Strings.swift +++ b/Sources/Shared/Resources/Swiftgen/Strings.swift @@ -1156,6 +1156,17 @@ public enum L10n { public static var close: String { return L10n.tr("Localizable", "navBar.close") } } + public enum Network { + public enum Error { + public enum NoActiveUrl { + /// Open companion app settings and check your server settings, internal URL will only be used if local network is defined (SSID), if you are using VPN try setting your external URL as the same as internal URL. + public static var body: String { return L10n.tr("Localizable", "network.error.no_active_url.body") } + /// No URL available to load + public static var title: String { return L10n.tr("Localizable", "network.error.no_active_url.title") } + } + } + } + public enum Nfc { /// Tag Read public static var genericTagRead: String { return L10n.tr("Localizable", "nfc.generic_tag_read") }