Skip to content

Commit

Permalink
Update connection details on main view to indicate that DAITA is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson committed Sep 6, 2024
1 parent e015870 commit 97ffc00
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ final class TunnelControlView: UIView {

updateSecureLabel(tunnelState: tunnelState)
updateActionButtons(tunnelState: tunnelState)
if tunnelState.isSecured {
updateTunnelRelays(tunnelRelays: tunnelState.relays)
} else {
updateTunnelRelays(tunnelRelays: nil)
}
updateTunnelRelays(tunnelStatus: model.tunnelStatus)
}

func setAnimatingActivity(_ isAnimating: Bool) {
Expand Down Expand Up @@ -226,18 +222,45 @@ final class TunnelControlView: UIView {
connectButtonBlurView.isEnabled = shouldEnableButtons
}

private func updateTunnelRelays(tunnelRelays: SelectedRelays?) {
if let tunnelRelays {
private func updateTunnelRelays(tunnelStatus: TunnelStatus) {
let tunnelState = tunnelStatus.state
let observedState = tunnelStatus.observedState

if tunnelState.isSecured, let tunnelRelays = tunnelState.relays {
cityLabel.attributedText = attributedStringForLocation(
string: tunnelRelays.exit.location.city
)
countryLabel.attributedText = attributedStringForLocation(
string: tunnelRelays.exit.location.country
)

let exitName = tunnelRelays.exit.hostname
let entryName = tunnelRelays.entry?.hostname
let usingDaita = observedState.connectionState?.isDaitaEnabled == true

let connectedRelayName = if let entryName {
String(format: NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: "%@ via %@ \(usingDaita ? "using DAITA" : "")",
comment: ""
), exitName, entryName)
} else {
String(format: NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: "%@ \(usingDaita ? "using DAITA" : "")",
comment: ""
), exitName)
}

connectionPanel.isHidden = false
connectionPanel.connectedRelayName = tunnelRelays.exit
.hostname + "\(tunnelRelays.entry.flatMap { " via \($0.hostname)" } ?? "")"
connectionPanel.connectedRelayName = NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: connectedRelayName,
comment: ""
)
} else {
countryLabel.attributedText = attributedStringForLocation(string: " ")
cityLabel.attributedText = attributedStringForLocation(string: " ")
Expand Down

0 comments on commit 97ffc00

Please sign in to comment.