Add shortcut for profile by key
This commit is contained in:
parent
dcd19fb8ed
commit
485fd091aa
|
@ -252,13 +252,16 @@ public class ConnectionService: Codable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func profile(withContext context: Context, id: String) -> ConnectionProfile? {
|
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]
|
var profile = cache[key]
|
||||||
if let _ = profile as? PlaceholderConnectionProfile {
|
if let _ = profile as? PlaceholderConnectionProfile {
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
do {
|
do {
|
||||||
let data = try profileData(key)
|
let data = try profileData(key)
|
||||||
switch context {
|
switch key.context {
|
||||||
case .provider:
|
case .provider:
|
||||||
profile = try decoder.decode(ProviderConnectionProfile.self, from: data)
|
profile = try decoder.decode(ProviderConnectionProfile.self, from: data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue