Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #1753: During rewards onboarding, create wallet and move on immed…
Browse files Browse the repository at this point in the history
…iately. (#1760)
  • Loading branch information
Brandon-T authored and kylehickinson committed Oct 22, 2019
1 parent 92cedc1 commit 48dda23
Showing 1 changed file with 3 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import BraveRewards

class OnboardingRewardsAgreementViewController: OnboardingViewController {

private var loadingView = UIActivityIndicatorView(style: .white)

private var contentView: View {
return view as! View // swiftlint:disable:this force_cast
}
Expand Down Expand Up @@ -51,37 +49,11 @@ class OnboardingRewardsAgreementViewController: OnboardingViewController {

@objc
private func onTurnOn() {
if loadingView.superview != nil || loadingView.isAnimating {
return
}

let titleColour = contentView.turnOnButton.titleColor(for: .normal)
contentView.turnOnButton.setTitleColor(.clear, for: .normal)
contentView.turnOnButton.isUserInteractionEnabled = false
contentView.skipButton.isUserInteractionEnabled = false
contentView.turnOnButton.addSubview(loadingView)
loadingView.snp.makeConstraints {
$0.center.equalToSuperview()
rewards?.ledger.createWalletAndFetchDetails { _ in
//TODO: Handle errors at a later date and possibly elsewhere..
}

loadingView.startAnimating()
rewards?.ledger.createWalletAndFetchDetails { [weak self] success in
guard let self = self else { return }

self.loadingView.stopAnimating()
self.loadingView.removeFromSuperview()
self.contentView.turnOnButton.setTitleColor(titleColour, for: .normal)
self.contentView.turnOnButton.isUserInteractionEnabled = true
self.contentView.skipButton.isUserInteractionEnabled = true

if success {
self.continueTapped()
} else {
let alert = UIAlertController(title: Strings.OBErrorTitle, message: Strings.OBErrorDetails, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: Strings.OBErrorOkay, style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
self.continueTapped()
}

override func applyTheme(_ theme: Theme) {
Expand Down

0 comments on commit 48dda23

Please sign in to comment.