macOS: Fix 'Network' entry in menu

This commit is contained in:
Roopesh Chander 2019-01-09 02:49:46 +05:30
parent 341f15678f
commit f68648f874
1 changed files with 9 additions and 5 deletions

View File

@ -86,12 +86,16 @@ class StatusMenu: NSMenu {
statusMenuItem.title = tr(format: "macStatus (%@)", statusText)
let addresses = tunnel.tunnelConfiguration?.interface.addresses ?? []
let addressesString = addresses.map { $0.stringRepresentation }.joined(separator: ", ")
if addressesString.isEmpty {
networksMenuItem.title = tr("macMenuNetworksNone")
if tunnel.status == .inactive {
networksMenuItem.title = tr("macMenuNetworksInactive")
} else {
networksMenuItem.title = tr(format: "macMenuNetworks (%@)", addressesString)
let addresses = tunnel.tunnelConfiguration?.interface.addresses ?? []
let addressesString = addresses.map { $0.stringRepresentation }.joined(separator: ", ")
if addressesString.isEmpty {
networksMenuItem.title = tr("macMenuNetworksNone")
} else {
networksMenuItem.title = tr(format: "macMenuNetworks (%@)", addressesString)
}
}
return true
}