Fix provider name ordering
Define intrinsecally with Comparable.
This commit is contained in:
parent
571cee7818
commit
cced9b018f
|
@ -56,7 +56,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
|
|||
}()
|
||||
|
||||
func reloadModel() {
|
||||
providers = service.ids(forContext: .provider)
|
||||
providers = service.ids(forContext: .provider).sorted()
|
||||
hosts = service.ids(forContext: .host).sortedCaseInsensitive()
|
||||
|
||||
var providerRows = [RowType](repeating: .profile, count: providers.count)
|
||||
|
@ -172,7 +172,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
|
|||
return
|
||||
}
|
||||
|
||||
availableProviderNames = names.sorted { $0.rawValue < $1.rawValue }
|
||||
availableProviderNames = names.sorted()
|
||||
perform(segue: StoryboardSegue.Organizer.addProviderSegueIdentifier)
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
|
|||
}
|
||||
|
||||
func sortedPools() -> [Pool] {
|
||||
return infrastructure.pools.sorted { $0.name < $1.name }
|
||||
return infrastructure.pools.sorted()
|
||||
}
|
||||
|
||||
private func validateEndpoint() {
|
||||
|
|
|
@ -27,12 +27,16 @@ import Foundation
|
|||
import TunnelKit
|
||||
|
||||
struct Infrastructure: Codable {
|
||||
enum Name: String, Codable {
|
||||
enum Name: String, Codable, Comparable {
|
||||
case pia = "PIA"
|
||||
|
||||
var webName: String {
|
||||
return rawValue.lowercased()
|
||||
}
|
||||
|
||||
static func <(lhs: Name, rhs: Name) -> Bool {
|
||||
return lhs.webName < rhs.webName
|
||||
}
|
||||
}
|
||||
|
||||
struct Defaults: Codable {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
import Foundation
|
||||
import TunnelKit
|
||||
|
||||
struct Pool: Codable, CustomStringConvertible {
|
||||
struct Pool: Codable, Comparable, CustomStringConvertible {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
|
||||
|
@ -68,7 +68,13 @@ struct Pool: Codable, CustomStringConvertible {
|
|||
addrs.insert(hostname, at: 0)
|
||||
return addrs
|
||||
}
|
||||
|
||||
// MARK: Comparable
|
||||
|
||||
static func <(lhs: Pool, rhs: Pool) -> Bool {
|
||||
return lhs.name < rhs.name
|
||||
}
|
||||
|
||||
// MARK: CustomStringConvertible
|
||||
|
||||
var description: String {
|
||||
|
|
Loading…
Reference in New Issue