diff --git a/jami-android/app/src/main/java/cx/ring/client/HomeActivity.kt b/jami-android/app/src/main/java/cx/ring/client/HomeActivity.kt index d290412d571929a0f8ac81f24792a9d178d2f7f0..8d1a677344b8255c5902190a6fb3fdaebbe6858e 100644 --- a/jami-android/app/src/main/java/cx/ring/client/HomeActivity.kt +++ b/jami-android/app/src/main/java/cx/ring/client/HomeActivity.kt @@ -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