Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions Apps/iOS/Services/RelayControlBackend+ConfigDefaults.swift

This file was deleted.

28 changes: 28 additions & 0 deletions Apps/iOS/Services/RelayControlBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,32 @@ extension RelayControlBackend {
false
}

func loadConfigText(id _: UUID) async -> String? {
await Task.yield()
return nil
}

func importConfig(url _: URL, name _: String) async {
await Task.yield()
}

func activateConfig(id _: UUID) async {
await Task.yield()
}

func saveConfigEdit(id _: UUID, text _: String) async {
await Task.yield()
}

func deleteConfig(id _: UUID) async {
await Task.yield()
}

func renameConfig(id _: UUID, name _: String) async {
await Task.yield()
}

func importConfig(name _: String, text _: String) async {
await Task.yield()
}
}
62 changes: 38 additions & 24 deletions Apps/iOS/Views/RelayScreenModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ private let logger = CellTunnelLog.logger(category: .app)
// MARK: - Constants

private let emptyValuePlaceholder = "(none)"
private let openLoginItemsTitle = "Open Login Items"

#if targetEnvironment(macCatalyst)
private let openLoginItemsTitle = "Open Login Items"
#endif

private let dataSectionTitle = "Data"
private let currentSpeedSectionTitle = "Current Speed"
private let connectingStatusLabel = "Connecting"
Expand Down Expand Up @@ -248,7 +252,7 @@ struct RelayScreenModel {
var status: RelayStatus {
RelayStatus(
errorMessage: controller.lastError,
isAgentInstalled: controller.isAgentInstalled,
isAgentInstalled: isAgentInstalled,
isTunnelInstalled: controller.isTunnelInstalled,
isActiveConfigPresent: controller.hasActiveConfig,
peersFound: peersAvailable,
Expand All @@ -257,6 +261,14 @@ struct RelayScreenModel {
)
}

private var isAgentInstalled: Bool {
#if targetEnvironment(macCatalyst)
return controller.isAgentInstalled
#else
return true
#endif
}

/// The status word the screens show, the state's label except while a turn-on
/// request is in flight, when it reads `Connecting` so the switch and the word
/// agree during the relay connect.
Expand Down Expand Up @@ -328,32 +340,34 @@ struct RelayScreenModel {
status.action
}

/// Installs the background agent, or opens Login Items when the agent is registered
/// but awaiting approval. The install-agent setup action.
func installAgent() {
logger.notice("relay screen install agent requested")
if controller.isAgentApprovalPending {
controller.openLoginItems()
} else {
controller.installAgent()
#if targetEnvironment(macCatalyst)
/// Installs the background agent, or opens Login Items when the agent is registered
/// but awaiting approval. The install-agent setup action.
func installAgent() {
logger.notice("relay screen install agent requested")
if controller.isAgentApprovalPending {
controller.openLoginItems()
} else {
controller.installAgent()
}
}
}

/// Installs the tunnel profile from the imported configuration. The install-tunnel
/// setup action.
func installTunnel(configURL: URL) {
logger.notice("relay screen install tunnel requested")
Task { await controller.installTunnel(configURL: configURL) }
}
/// Installs the tunnel profile from the imported configuration. The install-tunnel
/// setup action.
func installTunnel(configURL: URL) {
logger.notice("relay screen install tunnel requested")
Task { await controller.installTunnel(configURL: configURL) }
}

/// The title for the setup screen's primary action, deferring to the agent
/// approval state when the agent is registered but pending.
var setupActionTitle: String {
if status.action == .installAgent, controller.isAgentApprovalPending {
return openLoginItemsTitle
/// The title for the setup screen's primary action, deferring to the agent
/// approval state when the agent is registered but pending.
var setupActionTitle: String {
if status.action == .installAgent, controller.isAgentApprovalPending {
return openLoginItemsTitle
}
return status.action?.title ?? ""
}
return status.action?.title ?? ""
}
#endif

/// The runtime error message when the status is an error, shown as a row.
var errorMessage: String? {
Expand Down
Loading