diff --git a/Sources/App/Settings/Connection/ConnectionSettingsViewController.swift b/Sources/App/Settings/Connection/ConnectionSettingsViewController.swift index 3896cd064..c02c9b786 100644 --- a/Sources/App/Settings/Connection/ConnectionSettingsViewController.swift +++ b/Sources/App/Settings/Connection/ConnectionSettingsViewController.swift @@ -156,8 +156,7 @@ class ConnectionSettingsViewController: HAFormViewController, RowControllerType row.displayValueFor = { [server] _ in if server.info.connection.internalSSIDs?.isEmpty ?? true, server.info.connection.internalHardwareAddresses?.isEmpty ?? true, - !server.info.connection.alwaysFallbackToInternalURL, - !ConnectionInfo.shouldFallbackToInternalURL { + !server.info.connection.alwaysFallbackToInternalURL { return "‼️ \(L10n.Settings.ConnectionSection.InternalBaseUrl.RequiresSetup.title)" } else { return server.info.connection.address(for: .internal)?.absoluteString ?? "—" diff --git a/Sources/App/Settings/Connection/ConnectionURLViewController.swift b/Sources/App/Settings/Connection/ConnectionURLViewController.swift index 40b2641a2..25bd1a75e 100644 --- a/Sources/App/Settings/Connection/ConnectionURLViewController.swift +++ b/Sources/App/Settings/Connection/ConnectionURLViewController.swift @@ -232,8 +232,7 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle $0.tag = RowTag.internalURLWarning.rawValue if server.info.connection.internalSSIDs?.isEmpty ?? true, server.info.connection.internalHardwareAddresses?.isEmpty ?? true, - !server.info.connection.alwaysFallbackToInternalURL, - !ConnectionInfo.shouldFallbackToInternalURL { + !server.info.connection.alwaysFallbackToInternalURL { #if targetEnvironment(macCatalyst) $0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidBssidRequired.title #else @@ -297,41 +296,39 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle } } - if !ConnectionInfo.shouldFallbackToInternalURL { - form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer) - <<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) { - $0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title - $0.value = server.info.connection.alwaysFallbackToInternalURL + form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer) + <<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) { + $0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title + $0.value = server.info.connection.alwaysFallbackToInternalURL - $0.cellUpdate { cell, _ in - cell.switchControl.onTintColor = .red - } + $0.cellUpdate { cell, _ in + cell.switchControl.onTintColor = .red + } - $0.onChange { [weak self] row in - if row.value ?? false { - let alert = UIAlertController( - title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title, - message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message, - preferredStyle: .alert - ) - alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in - self?.server.info.connection.alwaysFallbackToInternalURL = false + $0.onChange { [weak self] row in + if row.value ?? false { + let alert = UIAlertController( + title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title, + message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message, + preferredStyle: .alert + ) + alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in + self?.server.info.connection.alwaysFallbackToInternalURL = false + row.value = false + row.cellUpdate { _, row in row.value = false - row.cellUpdate { _, row in - row.value = false - } - row.reload() - })) - alert.addAction(UIAlertAction( - title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation - .confirmButton, - style: .destructive - )) - self?.present(alert, animated: true) - } + } + row.reload() + })) + alert.addAction(UIAlertAction( + title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation + .confirmButton, + style: .destructive + )) + self?.present(alert, animated: true) } } - } + } } private func locationPermissionSection() -> Section { diff --git a/Sources/Shared/API/ConnectionInfo.swift b/Sources/Shared/API/ConnectionInfo.swift index a5917c3a8..7882cabcc 100644 --- a/Sources/Shared/API/ConnectionInfo.swift +++ b/Sources/Shared/API/ConnectionInfo.swift @@ -6,11 +6,6 @@ import Communicator #endif public struct ConnectionInfo: Codable, Equatable { - // TODO: Remove when location permission enforcement is in place - /// Developer toggle used while enforcement of location permision is not ready - /// Used as feature toggle - public static var shouldFallbackToInternalURL = true - private var externalURL: URL? private var internalURL: URL? private var remoteUIURL: URL? @@ -205,19 +200,13 @@ public struct ConnectionInfo: Codable, Equatable { activeURLType = .internal url = internalURL } else { - // TODO: Remove when location permission enforcement is in place - if ConnectionInfo.shouldFallbackToInternalURL { - activeURLType = .internal - url = internalURL - } else { - activeURLType = .none - url = nil - /* - No URL that can be used in this context is available - This can happen when only internal URL is set and - user tries to access the App remotely - */ - } + activeURLType = .none + url = nil + /* + No URL that can be used in this context is available + This can happen when only internal URL is set and + user tries to access the App remotely + */ } return url?.sanitized() diff --git a/Tests/Shared/ConnectionInfo.test.swift b/Tests/Shared/ConnectionInfo.test.swift index da422832a..c173271a4 100644 --- a/Tests/Shared/ConnectionInfo.test.swift +++ b/Tests/Shared/ConnectionInfo.test.swift @@ -3,10 +3,6 @@ import Version import XCTest class ConnectionInfoTests: XCTestCase { - override func setUp() async throws { - ConnectionInfo.shouldFallbackToInternalURL = false - } - func testInternalOnlyURL() { let url = URL(string: "http://example.com:8123") var info = ConnectionInfo(