Retain Pool.name internally but show .localizedName
Use name from API if available (XXX: not localized). Make it private to avoid unintended use in app.
This commit is contained in:
parent
3eb9c6ae98
commit
15f23dd448
|
@ -166,7 +166,7 @@ extension ShortcutsConnectToViewController {
|
||||||
let intent = MoveToLocationIntent()
|
let intent = MoveToLocationIntent()
|
||||||
intent.providerId = provider.id
|
intent.providerId = provider.id
|
||||||
intent.poolId = pool.id
|
intent.poolId = pool.id
|
||||||
intent.poolName = pool.name
|
intent.poolName = pool.localizedName
|
||||||
addShortcut(with: intent)
|
addShortcut(with: intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
|
||||||
let pool = pools[indexPath.row]
|
let pool = pools[indexPath.row]
|
||||||
|
|
||||||
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
||||||
cell.leftText = pool.name
|
cell.leftText = pool.localizedName
|
||||||
// cell.rightText = pool.area
|
// cell.rightText = pool.area
|
||||||
cell.applyChecked(pool.id == currentPoolId, Theme.current)
|
cell.applyChecked(pool.id == currentPoolId, Theme.current)
|
||||||
cell.isTappable = true
|
cell.isTappable = true
|
||||||
|
|
|
@ -620,7 +620,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
||||||
case .providerPool:
|
case .providerPool:
|
||||||
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
||||||
cell.leftText = L10n.Service.Cells.Provider.Pool.caption
|
cell.leftText = L10n.Service.Cells.Provider.Pool.caption
|
||||||
cell.rightText = uncheckedProviderProfile.pool?.name
|
cell.rightText = uncheckedProviderProfile.pool?.localizedName
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
case .providerPreset:
|
case .providerPreset:
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class IntentDispatcher {
|
||||||
let intent = MoveToLocationIntent()
|
let intent = MoveToLocationIntent()
|
||||||
intent.providerId = profile.id
|
intent.providerId = profile.id
|
||||||
intent.poolId = pool.id
|
intent.poolId = pool.id
|
||||||
intent.poolName = pool.name
|
intent.poolName = pool.localizedName
|
||||||
genericIntent = intent
|
genericIntent = intent
|
||||||
} else {
|
} else {
|
||||||
let intent = ConnectVPNIntent()
|
let intent = ConnectVPNIntent()
|
||||||
|
|
|
@ -45,7 +45,7 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
|
||||||
|
|
||||||
public let id: String
|
public let id: String
|
||||||
|
|
||||||
public let name: String
|
private let name: String
|
||||||
|
|
||||||
public let country: String
|
public let country: String
|
||||||
|
|
||||||
|
@ -74,16 +74,7 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
|
||||||
// MARK: Comparable
|
// MARK: Comparable
|
||||||
|
|
||||||
public static func <(lhs: Pool, rhs: Pool) -> Bool {
|
public static func <(lhs: Pool, rhs: Pool) -> Bool {
|
||||||
if lhs.name == rhs.name {
|
return lhs.localizedName < rhs.localizedName
|
||||||
guard let larea = lhs.area else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
guard let rarea = rhs.area else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return larea < rarea
|
|
||||||
}
|
|
||||||
return lhs.name < rhs.name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
@ -100,7 +91,13 @@ extension Pool {
|
||||||
return Utils.localizedCountry(country)
|
return Utils.localizedCountry(country)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String {
|
public var localizedName: String {
|
||||||
|
|
||||||
|
// XXX: name from API is not localized
|
||||||
|
if !name.isEmpty {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
let countryString = localizedCountry
|
let countryString = localizedCountry
|
||||||
guard let area = area else {
|
guard let area = area else {
|
||||||
return countryString
|
return countryString
|
||||||
|
|
Loading…
Reference in New Issue