Merge branch 'category-presets'
This commit is contained in:
commit
74d87754ea
|
@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Host compression framing and algorithm are now editable.
|
- Host compression framing and algorithm are now editable.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- NordVPN double servers not connecting out of the box. [#78](https://github.com/passepartoutvpn/passepartout-ios/issues/78)
|
||||||
|
|
||||||
## 1.6.0 (2019-05-01)
|
## 1.6.0 (2019-05-01)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -162,8 +162,13 @@ class ServiceViewController: UIViewController, TableModelHost {
|
||||||
vc?.modificationDelegate = self
|
vc?.modificationDelegate = self
|
||||||
|
|
||||||
case .providerPresetSegueIdentifier:
|
case .providerPresetSegueIdentifier:
|
||||||
|
let infra = uncheckedProviderProfile.infrastructure
|
||||||
|
let presets: [InfrastructurePreset] = uncheckedProviderProfile.pool?.supportedPresetIds(in: uncheckedProviderProfile.infrastructure).map {
|
||||||
|
return infra.preset(for: $0)!
|
||||||
|
} ?? []
|
||||||
|
|
||||||
let vc = destination as? ProviderPresetViewController
|
let vc = destination as? ProviderPresetViewController
|
||||||
vc?.presets = uncheckedProviderProfile.infrastructure.presets
|
vc?.presets = presets
|
||||||
vc?.currentPresetId = uncheckedProviderProfile.presetId
|
vc?.currentPresetId = uncheckedProviderProfile.presetId
|
||||||
vc?.delegate = self
|
vc?.delegate = self
|
||||||
|
|
||||||
|
@ -631,6 +636,13 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var providerPresetIndexPath: IndexPath {
|
||||||
|
guard let ip = model.indexPath(row: .providerPreset, section: .configuration) else {
|
||||||
|
fatalError("Could not locate presetIndexPath")
|
||||||
|
}
|
||||||
|
return ip
|
||||||
|
}
|
||||||
|
|
||||||
private func mappedTrustedNetworksRow(_ from: TrustedNetworksModel.RowType) -> RowType {
|
private func mappedTrustedNetworksRow(_ from: TrustedNetworksModel.RowType) -> RowType {
|
||||||
switch from {
|
switch from {
|
||||||
case .trustsMobile:
|
case .trustsMobile:
|
||||||
|
@ -1122,13 +1134,13 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
||||||
tableView.reloadRows(at: [dataCountIndexPath], with: .none)
|
tableView.reloadRows(at: [dataCountIndexPath], with: .none)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadSelectedRow(andRowAt indexPath: IndexPath? = nil) {
|
func reloadSelectedRow(andRowsAt indexPaths: [IndexPath]? = nil) {
|
||||||
guard let selectedIP = tableView.indexPathForSelectedRow else {
|
guard let selectedIP = tableView.indexPathForSelectedRow else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var outdatedIPs = [selectedIP]
|
var outdatedIPs = [selectedIP]
|
||||||
if let otherIP = indexPath {
|
if let otherIPs = indexPaths {
|
||||||
outdatedIPs.append(otherIP)
|
outdatedIPs.append(contentsOf: otherIPs)
|
||||||
}
|
}
|
||||||
tableView.reloadRows(at: outdatedIPs, with: .none)
|
tableView.reloadRows(at: outdatedIPs, with: .none)
|
||||||
tableView.selectRow(at: selectedIP, animated: false, scrollPosition: .none)
|
tableView.selectRow(at: selectedIP, animated: false, scrollPosition: .none)
|
||||||
|
@ -1254,7 +1266,21 @@ extension ServiceViewController: ProviderPoolViewControllerDelegate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uncheckedProviderProfile.poolId = pool.id
|
uncheckedProviderProfile.poolId = pool.id
|
||||||
reloadSelectedRow(andRowAt: endpointIndexPath)
|
|
||||||
|
var extraReloadedRows = [endpointIndexPath]
|
||||||
|
|
||||||
|
// fall back to a supported preset and reload preset row too
|
||||||
|
let supportedPresets = pool.supportedPresetIds(in: uncheckedProviderProfile.infrastructure)
|
||||||
|
if let presetId = uncheckedProviderProfile.preset?.id, !supportedPresets.contains(presetId),
|
||||||
|
let fallback = supportedPresets.first {
|
||||||
|
|
||||||
|
if fallback != uncheckedProviderProfile.presetId {
|
||||||
|
extraReloadedRows.append(providerPresetIndexPath)
|
||||||
|
}
|
||||||
|
uncheckedProviderProfile.presetId = fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadSelectedRow(andRowsAt: extraReloadedRows)
|
||||||
vpn.reinstallIfEnabled()
|
vpn.reinstallIfEnabled()
|
||||||
|
|
||||||
if #available(iOS 12, *) {
|
if #available(iOS 12, *) {
|
||||||
|
@ -1271,7 +1297,7 @@ extension ServiceViewController: ProviderPresetViewControllerDelegate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uncheckedProviderProfile.presetId = preset.id
|
uncheckedProviderProfile.presetId = preset.id
|
||||||
reloadSelectedRow(andRowAt: endpointIndexPath)
|
reloadSelectedRow(andRowsAt: [endpointIndexPath])
|
||||||
vpn.reinstallIfEnabled()
|
vpn.reinstallIfEnabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -29,4 +29,6 @@ public struct PoolCategory: Codable {
|
||||||
public let name: String
|
public let name: String
|
||||||
|
|
||||||
public let groups: [PoolGroup]
|
public let groups: [PoolGroup]
|
||||||
|
|
||||||
|
public let presets: [String]?
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,25 @@ public struct Pool: Codable, Hashable {
|
||||||
|
|
||||||
public let numericAddresses: [UInt32]?
|
public let numericAddresses: [UInt32]?
|
||||||
|
|
||||||
|
// XXX: inefficient but convenient field (not serialized)
|
||||||
|
public func category(in infrastructure: Infrastructure) -> PoolCategory? {
|
||||||
|
for category in infrastructure.categories {
|
||||||
|
for group in category.groups {
|
||||||
|
for pool in group.pools {
|
||||||
|
if pool.id == id {
|
||||||
|
return category
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public func supportedPresetIds(in infrastructure: Infrastructure) -> [String] {
|
||||||
|
let poolCategory = category(in: infrastructure)
|
||||||
|
return poolCategory?.presets ?? infrastructure.presets.map { $0.id }
|
||||||
|
}
|
||||||
|
|
||||||
public func hasAddress(_ address: String) -> Bool {
|
public func hasAddress(_ address: String) -> Bool {
|
||||||
guard let numericAddresses = numericAddresses else {
|
guard let numericAddresses = numericAddresses else {
|
||||||
return false
|
return false
|
||||||
|
@ -88,6 +107,12 @@ public struct Pool: Codable, Hashable {
|
||||||
return addrs
|
return addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Equatable
|
||||||
|
|
||||||
|
public static func == (lhs: Pool, rhs: Pool) -> Bool {
|
||||||
|
return lhs.id == rhs.id
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Hashable
|
// MARK: Hashable
|
||||||
|
|
||||||
public func hash(into hasher: inout Hasher) {
|
public func hash(into hasher: inout Hasher) {
|
||||||
|
|
Loading…
Reference in New Issue