From 485fd091aae4ba343d7c3eebbd2f61bd5e963f1a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Apr 2019 00:08:53 +0200 Subject: [PATCH] Add shortcut for profile by key --- Passepartout/Sources/Model/ConnectionService.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Passepartout/Sources/Model/ConnectionService.swift b/Passepartout/Sources/Model/ConnectionService.swift index f708bff3..1f4e1bf1 100644 --- a/Passepartout/Sources/Model/ConnectionService.swift +++ b/Passepartout/Sources/Model/ConnectionService.swift @@ -252,13 +252,16 @@ public class ConnectionService: Codable { } public func profile(withContext context: Context, id: String) -> ConnectionProfile? { - let key = ProfileKey(context, id) + return profile(withKey: ProfileKey(context, id)) + } + + public func profile(withKey key: ProfileKey) -> ConnectionProfile? { var profile = cache[key] if let _ = profile as? PlaceholderConnectionProfile { let decoder = JSONDecoder() do { let data = try profileData(key) - switch context { + switch key.context { case .provider: profile = try decoder.decode(ProviderConnectionProfile.self, from: data)