From 8e1b67d151bbbe69a48a601b9bd3fe3b451b049a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 25 Oct 2018 23:08:43 +0200 Subject: [PATCH] Infer profile id uniqueness by context Drop "(provider|host)." prefix, reuse as title. --- .../Scenes/Organizer/OrganizerViewController.swift | 2 +- Passepartout-iOS/Scenes/ServiceViewController.swift | 4 ++-- Passepartout/Sources/Model/ConnectionProfile.swift | 2 -- .../Sources/Model/Profiles/HostConnectionProfile.swift | 6 +++--- .../Sources/Model/Profiles/ProviderConnectionProfile.swift | 5 +---- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index bb152e47..f3a7cd3d 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -313,7 +313,7 @@ extension OrganizerViewController { case .profile: let cell = Cells.setting.dequeue(from: tableView, for: indexPath) let rowProfile = profile(at: indexPath) - cell.leftText = rowProfile.title + cell.leftText = rowProfile.id cell.rightText = service.isActiveProfile(rowProfile) ? L10n.Organizer.Cells.Profile.Value.current : nil return cell diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 45dab7a0..36349032 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -37,7 +37,7 @@ class ServiceViewController: UIViewController, TableModelHost { var profile: ConnectionProfile? { didSet { - title = profile?.title + title = profile?.id reloadModel() updateViewsIfNeeded() } @@ -78,7 +78,7 @@ class ServiceViewController: UIViewController, TableModelHost { lastInfrastructureUpdate = InfrastructureFactory.shared.modificationDate(for: providerProfile.name) } - title = profile?.title + title = profile?.id navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem navigationItem.leftItemsSupplementBackButton = true diff --git a/Passepartout/Sources/Model/ConnectionProfile.swift b/Passepartout/Sources/Model/ConnectionProfile.swift index 53777d7a..13e7ee80 100644 --- a/Passepartout/Sources/Model/ConnectionProfile.swift +++ b/Passepartout/Sources/Model/ConnectionProfile.swift @@ -29,8 +29,6 @@ import NetworkExtension protocol ConnectionProfile: class, EndpointDataSource { var id: String { get } - - var title: String { get } var username: String? { get set } diff --git a/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift index fc5fb075..4d68c4ce 100644 --- a/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift +++ b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift @@ -27,6 +27,8 @@ import Foundation import TunnelKit class HostConnectionProfile: ConnectionProfile, Codable, Equatable { + var title: String + let hostname: String var parameters: TunnelKitProvider.Configuration @@ -41,10 +43,8 @@ class HostConnectionProfile: ConnectionProfile, Codable, Equatable { // MARK: ConnectionProfile var id: String { - return "host.\(title)" + return title } - - var title: String var username: String? diff --git a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift index c23914b3..394ac632 100644 --- a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift +++ b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift @@ -66,7 +66,6 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable { poolId = "" presetId = "" - id = "provider.\(name.rawValue)" username = nil poolId = infrastructure.defaults.pool @@ -93,9 +92,7 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable { // MARK: ConnectionProfile - let id: String - - var title: String { + var id: String { return name.rawValue }