From 35f4a558016b5b05b64f355d0a59bcddc34fa881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 27 May 2024 11:53:44 -0400 Subject: [PATCH] HomeActivity: use proper account to lookup username Change-Id: I5d0b6bcde6e124ef2d1a129f2305c03bc26b5f19 --- .../app/src/main/java/cx/ring/client/HomeActivity.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 d290412d5..8d1a67734 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 -- GitLab