Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connection details on main view to indicate that DAITA is used #6719

Merged
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
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
Loading