Skip to content

Commit 9208e55

Browse files
authored
Revert "Adding back warning about internal URL usage" (#3419)
Reverts #3341 Reverting while we redesign this flow for a better UX for non-technical users
1 parent 3a709db commit 9208e55

File tree

4 files changed

+56
-37
lines changed

4 files changed

+56
-37
lines changed

Sources/App/Settings/Connection/ConnectionSettingsViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ class ConnectionSettingsViewController: HAFormViewController, RowControllerType
156156
row.displayValueFor = { [server] _ in
157157
if server.info.connection.internalSSIDs?.isEmpty ?? true,
158158
server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
159-
!server.info.connection.alwaysFallbackToInternalURL {
159+
!server.info.connection.alwaysFallbackToInternalURL,
160+
!ConnectionInfo.shouldFallbackToInternalURL {
160161
return "‼️ \(L10n.Settings.ConnectionSection.InternalBaseUrl.RequiresSetup.title)"
161162
} else {
162163
return server.info.connection.address(for: .internal)?.absoluteString ?? ""

Sources/App/Settings/Connection/ConnectionURLViewController.swift

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle
232232
$0.tag = RowTag.internalURLWarning.rawValue
233233
if server.info.connection.internalSSIDs?.isEmpty ?? true,
234234
server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
235-
!server.info.connection.alwaysFallbackToInternalURL {
235+
!server.info.connection.alwaysFallbackToInternalURL,
236+
!ConnectionInfo.shouldFallbackToInternalURL {
236237
#if targetEnvironment(macCatalyst)
237238
$0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidBssidRequired.title
238239
#else
@@ -296,39 +297,41 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle
296297
}
297298
}
298299

299-
form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer)
300-
<<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) {
301-
$0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title
302-
$0.value = server.info.connection.alwaysFallbackToInternalURL
300+
if !ConnectionInfo.shouldFallbackToInternalURL {
301+
form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer)
302+
<<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) {
303+
$0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title
304+
$0.value = server.info.connection.alwaysFallbackToInternalURL
303305

304-
$0.cellUpdate { cell, _ in
305-
cell.switchControl.onTintColor = .red
306-
}
306+
$0.cellUpdate { cell, _ in
307+
cell.switchControl.onTintColor = .red
308+
}
307309

308-
$0.onChange { [weak self] row in
309-
if row.value ?? false {
310-
let alert = UIAlertController(
311-
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title,
312-
message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message,
313-
preferredStyle: .alert
314-
)
315-
alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in
316-
self?.server.info.connection.alwaysFallbackToInternalURL = false
317-
row.value = false
318-
row.cellUpdate { _, row in
310+
$0.onChange { [weak self] row in
311+
if row.value ?? false {
312+
let alert = UIAlertController(
313+
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title,
314+
message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message,
315+
preferredStyle: .alert
316+
)
317+
alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in
318+
self?.server.info.connection.alwaysFallbackToInternalURL = false
319319
row.value = false
320-
}
321-
row.reload()
322-
}))
323-
alert.addAction(UIAlertAction(
324-
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation
325-
.confirmButton,
326-
style: .destructive
327-
))
328-
self?.present(alert, animated: true)
320+
row.cellUpdate { _, row in
321+
row.value = false
322+
}
323+
row.reload()
324+
}))
325+
alert.addAction(UIAlertAction(
326+
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation
327+
.confirmButton,
328+
style: .destructive
329+
))
330+
self?.present(alert, animated: true)
331+
}
329332
}
330333
}
331-
}
334+
}
332335
}
333336

334337
private func locationPermissionSection() -> Section {

Sources/Shared/API/ConnectionInfo.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import Communicator
66
#endif
77

88
public struct ConnectionInfo: Codable, Equatable {
9+
// TODO: Remove when location permission enforcement is in place
10+
/// Developer toggle used while enforcement of location permision is not ready
11+
/// Used as feature toggle
12+
public static var shouldFallbackToInternalURL = true
13+
914
private var externalURL: URL?
1015
private var internalURL: URL?
1116
private var remoteUIURL: URL?
@@ -200,13 +205,19 @@ public struct ConnectionInfo: Codable, Equatable {
200205
activeURLType = .internal
201206
url = internalURL
202207
} else {
203-
activeURLType = .none
204-
url = nil
205-
/*
206-
No URL that can be used in this context is available
207-
This can happen when only internal URL is set and
208-
user tries to access the App remotely
209-
*/
208+
// TODO: Remove when location permission enforcement is in place
209+
if ConnectionInfo.shouldFallbackToInternalURL {
210+
activeURLType = .internal
211+
url = internalURL
212+
} else {
213+
activeURLType = .none
214+
url = nil
215+
/*
216+
No URL that can be used in this context is available
217+
This can happen when only internal URL is set and
218+
user tries to access the App remotely
219+
*/
220+
}
210221
}
211222

212223
return url?.sanitized()

Tests/Shared/ConnectionInfo.test.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import Version
33
import XCTest
44

55
class ConnectionInfoTests: XCTestCase {
6+
override func setUp() async throws {
7+
ConnectionInfo.shouldFallbackToInternalURL = false
8+
}
9+
610
func testInternalOnlyURL() {
711
let url = URL(string: "http://example.com:8123")
812
var info = ConnectionInfo(

0 commit comments

Comments
 (0)