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 4, 2024
1 parent 62b3c6d commit a687981
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "c15149b2d59d9e9c72375f65339c04f41a19943e1117e682df27fc9f943fdc56",
"pins" : [
{
"identity" : "swift-log",
Expand All @@ -18,5 +19,5 @@
}
}
],
"version" : 2
"version" : 3
}
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 @@ -144,11 +144,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 @@ -224,18 +220,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 a687981

Please sign in to comment.