Skip to content
Snippets Groups Projects
Commit 35f4a558 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

HomeActivity: use proper account to lookup username

Change-Id: I5d0b6bcde6e124ef2d1a129f2305c03bc26b5f19
parent 05aede40
No related branches found
No related tags found
No related merge requests found
......@@ -329,15 +329,13 @@ class HomeActivity : AppCompatActivity(), ContactPickerFragment.OnContactedPicke
// Subject to check if a username is available
val usernameAvailabilitySubject = PublishSubject.create<String>()
val usernameIsAvailableObservable =
usernameAvailabilitySubject
mDisposable.add(
mAccountService.currentAccountSubject
.switchMap { account -> usernameAvailabilitySubject.map { Pair(account, it) } }
.debounce(500, TimeUnit.MILLISECONDS)
.switchMapSingle { mAccountService.findRegistrationByName("", "", it) }
.switchMapSingle { (account, username) -> mAccountService.findRegistrationByName(account.accountId, "", username) }
.observeOn(DeviceUtils.uiScheduler)
mDisposable.add(
usernameIsAvailableObservable.subscribe {
welcomeJamiViewModel.checkIfUsernameIsAvailableResult(it)
}
.subscribe { welcomeJamiViewModel.checkIfUsernameIsAvailableResult(it) }
)
// Subscribe on account to display correct welcome fragment
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment