account/profile creation: bugs fixes
- show the "Create account" spinner just after clicking the create account button, and
not after few seconds as was the case
- show just one create profile page after the account was created, and not two
as was the case
Change-Id: Iea253a53284b68d2e7363de12ac597f7288587aa
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
index 7862e26..10e9414 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
@@ -145,7 +145,12 @@
// Bind View Actions to ViewModel
self.createAccountButton.rx.tap.subscribe(onNext: { [unowned self] in
- self.viewModel.createAccount()
+ DispatchQueue.main.async {
+ self.showAccountCreationInProgress()
+ }
+ DispatchQueue.global(qos: .background).async {
+ self.viewModel.createAccount()
+ }
}).disposed(by: self.disposeBag)
}
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
index 94cc381..6c71f3b 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift
@@ -214,6 +214,7 @@
}()
required init (with injectionBag: InjectionBag) {
+ var isPageDisplayed = false
self.accountService = injectionBag.accountService
self.nameService = injectionBag.nameService
@@ -260,9 +261,12 @@
.subscribe(onNext: { [unowned self] event in
if event.getEventInput(ServiceEventInput.registrationState) == Unregistered {
self.accountCreationState.value = .success
- Observable<Int>.timer(Durations.alertFlashDuration.value, period: nil, scheduler: MainScheduler.instance).subscribe(onNext: { [unowned self] (_) in
- self.stateSubject.onNext(WalkthroughState.accountCreated)
- }).disposed(by: self.disposeBag)
+ if !isPageDisplayed {
+ DispatchQueue.main.async {
+ self.stateSubject.onNext(WalkthroughState.accountCreated)
+ }
+ isPageDisplayed = true
+ }
} else if event.getEventInput(ServiceEventInput.registrationState) == ErrorGeneric {
self.accountCreationState.value = .error(error: AccountCreationError.generic)
} else if event.getEventInput(ServiceEventInput.registrationState) == ErrorNetwork {