Make sure that provider infrastructure exists
Download in wizard if necessary.
This commit is contained in:
parent
c1c7587c8c
commit
bbd19427d9
|
@ -58,22 +58,50 @@ class WizardProviderViewController: UITableViewController, StrongTableHost {
|
|||
reloadModel()
|
||||
}
|
||||
|
||||
private func next(withMetadata metadata: Infrastructure.Metadata) {
|
||||
private func tryNext(withMetadata metadata: Infrastructure.Metadata) {
|
||||
guard ProductManager.shared.isEligible(forProvider: metadata.name) else {
|
||||
presentPurchaseScreen(forProduct: metadata.product)
|
||||
return
|
||||
}
|
||||
|
||||
// make sure that infrastructure exists locally
|
||||
guard let _ = InfrastructureFactory.shared.infrastructure(forName: metadata.name) else {
|
||||
let hud = HUD(view: view)
|
||||
_ = InfrastructureFactory.shared.update(metadata.name, notBeforeInterval: nil) { [weak self] in
|
||||
hud.hide()
|
||||
guard let _ = $0 else {
|
||||
self?.alertMissingInfrastructure(forName: metadata.name, error: $1)
|
||||
return
|
||||
}
|
||||
self?.next(withMetadata: metadata)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
next(withMetadata: metadata)
|
||||
}
|
||||
|
||||
private func next(withMetadata metadata: Infrastructure.Metadata) {
|
||||
let profile = ProviderConnectionProfile(name: metadata.name)
|
||||
createdProfile = profile
|
||||
|
||||
let accountVC = StoryboardScene.Main.accountIdentifier.instantiate()
|
||||
let infrastructure = InfrastructureFactory.shared.infrastructure(forName: metadata.name)
|
||||
guard let infrastructure = InfrastructureFactory.shared.infrastructure(forName: metadata.name) else {
|
||||
fatalError("Moving to credentials with nil infrastructure, not downloaded properly?")
|
||||
}
|
||||
accountVC.usernamePlaceholder = infrastructure.defaults.username
|
||||
accountVC.infrastructureName = infrastructure.name
|
||||
accountVC.delegate = self
|
||||
navigationController?.pushViewController(accountVC, animated: true)
|
||||
}
|
||||
|
||||
private func alertMissingInfrastructure(forName name: Infrastructure.Name, error: Error?) {
|
||||
log.error("Unable to download missing \(name) infrastructure: \(error?.localizedDescription ?? "")")
|
||||
|
||||
let alert = UIAlertController.asAlert(title, "..........")
|
||||
alert.addCancelAction(L10n.Core.Global.ok)
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func finish(withCredentials credentials: Credentials) {
|
||||
guard let profile = createdProfile else {
|
||||
|
@ -157,7 +185,7 @@ extension WizardProviderViewController {
|
|||
switch row {
|
||||
case .provider:
|
||||
let metadata = available[indexPath.row]
|
||||
next(withMetadata: metadata)
|
||||
tryNext(withMetadata: metadata)
|
||||
|
||||
case .updateList:
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5e25f768fb66832c4a539e7ff6ba7fa80d918a12
|
||||
Subproject commit 725a121ed811fc014267ebf1e4307a10ab570639
|
Loading…
Reference in New Issue