Commit 9f9facb8 authored by Jose Blaya's avatar Jose Blaya

Refactor

parent 0a668e29
......@@ -203,7 +203,7 @@ public class Server: Hashable {
self.dipToken = dipToken
self.dipStatus = dipStatus
isAutomatic = true
isAutomatic = false
}
// MARK: Hashable
......
......@@ -88,6 +88,10 @@ public final class Client {
ServersDaemon.shared.forceUpdates(completionBlock: completionBlock)
}
public static func resetWebServices() {
Client.webServices = PIAWebServices()
}
/**
Refresh the list of plan products
*/
......
......@@ -251,31 +251,4 @@ class GlossServersBundle: GlossParser {
}
func parseLegacyData(_ json: JSON) {
let glossConfiguration: GlossServersBundle.Configuration? = "info" <~~ json
var servers: [Server] = []
for (code, serverDict) in json {
guard let serverJSON = serverDict as? JSON else {
continue
}
guard let _ = serverJSON["country"] as? String else {
continue
}
guard let server = GlossServer(json: serverJSON)?.parsed else {
continue
}
server.isAutomatic = glossConfiguration?.parsed.automaticIdentifiers?.contains(code) ?? true
servers.append(server)
}
servers.sort { $0.name < $1.name }
parsed = ServersBundle(
servers: servers,
configuration: glossConfiguration?.parsed
)
}
}
......@@ -126,11 +126,10 @@ public class PIAWelcomeViewController: AutolayoutViewController, WelcomeCompleti
@IBAction private func toggleEnvironment(_ sender: Any?) {
if (Client.environment == .production) {
Client.environment = .staging
Client.webServices = PIAWebServices()
} else {
Client.environment = .production
Client.webServices = PIAWebServices()
}
Client.resetWebServices()
refreshEnvironmentButton()
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment