diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift index fac8dd30..ea3f7fa9 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsConnectToViewController.swift @@ -89,7 +89,7 @@ class ShortcutsConnectToViewController: UITableViewController, ProviderPoolViewC guard let provider = selectedProfile as? ProviderConnectionProfile else { return } - vc.setPools(provider.pools()) + vc.setPools(provider.pools(), currentPoolId: nil) vc.delegate = self } diff --git a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift index 032410b5..dff6d00f 100644 --- a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift @@ -37,11 +37,11 @@ class ProviderPoolViewController: UIViewController { private var sortedGroups: [PoolGroup] = [] - var currentPoolId: String? + private var currentPool: Pool? weak var delegate: ProviderPoolViewControllerDelegate? - func setPools(_ pools: [Pool]) { + func setPools(_ pools: [Pool], currentPoolId: String?) { for p in pools { poolsByGroup[p.group()] = [p] } @@ -72,7 +72,7 @@ class ProviderPoolViewController: UIViewController { extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate { private var selectedIndexPath: IndexPath? { for entries in poolsByGroup.enumerated() { - guard let _ = entries.element.value.index(where: { $0.id == currentPoolId }) else { + guard let _ = entries.element.value.index(where: { $0.id == currentPool?.id }) else { continue } guard let row = sortedGroups.index(of: entries.element.key) else { @@ -96,7 +96,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate cell.imageView?.image = pool.logo cell.leftText = pool.localizedName cell.rightText = pool.areaId?.uppercased() - cell.applyChecked(pool.id == currentPoolId, Theme.current) + cell.applyChecked(pool.id == currentPool?.id, Theme.current) cell.isTappable = true return cell } @@ -106,7 +106,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate let groupPools = poolsByGroup[group] let pool = groupPools!.first! - currentPoolId = pool.id + currentPool = pool delegate?.providerPoolController(self, didSelectPool: pool) } } diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 2f46c276..1ac89003 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -151,8 +151,7 @@ class ServiceViewController: UIViewController, TableModelHost { case .providerPoolSegueIdentifier: let vc = destination as? ProviderPoolViewController - vc?.setPools(uncheckedProviderProfile.pools()) - vc?.currentPoolId = uncheckedProviderProfile.poolId + vc?.setPools(uncheckedProviderProfile.pools(), currentPoolId: uncheckedProviderProfile.poolId) vc?.delegate = self case .endpointSegueIdentifier: