Use correct homeserver url to check qr code login support.

This commit is contained in:
Onuray Sahin 2022-10-14 17:46:14 +03:00
parent b04ad4915f
commit e83bdc3779
4 changed files with 7 additions and 7 deletions

View File

@ -25,6 +25,7 @@ import com.airbnb.mvrx.viewModel
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.lib.core.utils.compat.getParcelableCompat
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import timber.log.Timber import timber.log.Timber
@ -37,7 +38,7 @@ class QrCodeLoginActivity : SimpleFragmentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
views.toolbar.visibility = View.GONE views.toolbar.visibility = View.GONE
val qrCodeLoginArgs: QrCodeLoginArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG) val qrCodeLoginArgs: QrCodeLoginArgs? = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG)
if (isFirstCreation()) { if (isFirstCreation()) {
when (qrCodeLoginArgs?.loginType) { when (qrCodeLoginArgs?.loginType) {
QrCodeLoginType.LOGIN -> { QrCodeLoginType.LOGIN -> {

View File

@ -44,7 +44,7 @@ class QrCodeLoginShowQrCodeFragment : VectorBaseFragment<FragmentQrCodeLoginShow
private fun initCancelButton() { private fun initCancelButton() {
views.qrCodeLoginShowQrCodeCancelButton.debouncedClicks { views.qrCodeLoginShowQrCodeCancelButton.debouncedClicks {
activity?.onBackPressed() activity?.onBackPressedDispatcher?.onBackPressed()
} }
} }

View File

@ -45,7 +45,7 @@ class QrCodeLoginStatusFragment : VectorBaseFragment<FragmentQrCodeLoginStatusBi
private fun initCancelButton() { private fun initCancelButton() {
views.qrCodeLoginStatusCancelButton.debouncedClicks { views.qrCodeLoginStatusCancelButton.debouncedClicks {
activity?.onBackPressed() activity?.onBackPressedDispatcher?.onBackPressed()
} }
} }

View File

@ -118,7 +118,7 @@ class OnboardingViewModel @AssistedInject constructor(
} }
} }
private fun observeQrCodeLoginCapability() = viewModelScope.launch { private fun observeQrCodeLoginCapability(homeServerUrl: String) = viewModelScope.launch {
if (!vectorFeatures.isQrCodeLoginEnabled()) { if (!vectorFeatures.isQrCodeLoginEnabled()) {
setState { setState {
copy( copy(
@ -134,8 +134,7 @@ class OnboardingViewModel @AssistedInject constructor(
} }
} else { } else {
// check if selected server supports MSC3882 first // check if selected server supports MSC3882 first
// FIXME: this should be checking the selected homeserver not defaultHomeserverUrl homeServerConnectionConfigFactory.create(homeServerUrl)?.let {
homeServerConnectionConfigFactory.create(defaultHomeserverUrl)?.let {
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it) val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
setState { setState {
copy( copy(
@ -263,7 +262,6 @@ class OnboardingViewModel @AssistedInject constructor(
private fun handleSplashAction(action: OnboardingAction.SplashAction) { private fun handleSplashAction(action: OnboardingAction.SplashAction) {
setState { copy(onboardingFlow = action.onboardingFlow) } setState { copy(onboardingFlow = action.onboardingFlow) }
continueToPageAfterSplash(action.onboardingFlow) continueToPageAfterSplash(action.onboardingFlow)
observeQrCodeLoginCapability()
} }
private fun continueToPageAfterSplash(onboardingFlow: OnboardingFlow) { private fun continueToPageAfterSplash(onboardingFlow: OnboardingFlow) {
@ -709,6 +707,7 @@ class OnboardingViewModel @AssistedInject constructor(
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig"))) _viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
} else { } else {
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction) startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
observeQrCodeLoginCapability(homeServerConnectionConfig.homeServerUri.toString())
} }
} }