Use wrappers for profile metadata

Contextually fix provider appearance in Siri shortcuts. Was using
name (lowercase) rather than description (fancy).
This commit is contained in:
Davide De Rosa 2020-02-27 01:03:37 +01:00
parent 7a0b3b8e52
commit c7b2ff56b5
5 changed files with 11 additions and 11 deletions

View File

@ -208,7 +208,7 @@ class ProductManager: NSObject {
log.debug("Checking 'Unlimited hosts'")
if !isEligible(forFeature: .unlimitedHosts) {
let ids = service.ids(forContext: .host)
let ids = service.currentHostNames()
if ids.count > AppConstants.InApp.limitedNumberOfHosts {
for id in ids {
service.removeProfile(ProfileKey(.host, id))
@ -246,7 +246,7 @@ class ProductManager: NSObject {
extension ConnectionService {
var hasReachedMaximumNumberOfHosts: Bool {
let numberOfHosts = ids(forContext: .host).count
let numberOfHosts = currentHostNames().count
return numberOfHosts >= AppConstants.InApp.limitedNumberOfHosts
}
}

View File

@ -85,8 +85,8 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
//
providers = service.ids(forContext: .provider).sorted()
hosts = service.ids(forContext: .host).sortedCaseInsensitive()
providers = service.currentProviderNames().sorted()
hosts = service.currentHostNames().sortedCaseInsensitive()
var providerRows = [RowType](repeating: .profile, count: providers.count)
var hostRows = [RowType](repeating: .profile, count: hosts.count)

View File

@ -35,7 +35,7 @@ class WizardHostViewController: UITableViewController, StrongTableHost {
@IBOutlet private weak var itemNext: UIBarButtonItem!
private let existingHosts: [String] = {
return TransientStore.shared.service.ids(forContext: .host).sortedCaseInsensitive()
return TransientStore.shared.service.currentHostNames().sortedCaseInsensitive()
}()
var parsingResult: OpenVPN.ConfigurationParser.Result? {

View File

@ -33,7 +33,7 @@ import Convenience
class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewControllerDelegate, StrongTableHost {
private let service = TransientStore.shared.service
private var providers: [String] = []
private var providers: [Infrastructure.Metadata] = []
private var hosts: [String] = []
@ -51,8 +51,8 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC
}()
func reloadModel() {
providers = service.ids(forContext: .provider).sorted()
hosts = service.ids(forContext: .host).sortedCaseInsensitive()
providers = service.currentProviderMetadata().sorted()
hosts = service.currentHostNames().sortedCaseInsensitive()
if !providers.isEmpty {
model.add(.providers)
@ -124,7 +124,7 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
switch model.row(at: indexPath) {
case .providerShortcut:
cell.leftText = providers[indexPath.row]
cell.leftText = providers[indexPath.row].description
case .hostShortcut:
cell.leftText = hosts[indexPath.row]
@ -135,7 +135,7 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch model.row(at: indexPath) {
case .providerShortcut:
selectedProfile = service.profile(withContext: .provider, id: providers[indexPath.row])
selectedProfile = service.profile(withContext: .provider, id: providers[indexPath.row].name)
pickProviderLocation()
case .hostShortcut:

@ -1 +1 @@
Subproject commit bec079519b8095222644e9ba795e9b4d3bed7149
Subproject commit 149e95d9727e504c96b3e6ec0d822c195782299a