mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Fix crash when invalid url is entered #7672
This commit is contained in:
parent
c20500ab7a
commit
341967bf3c
1 changed files with 9 additions and 12 deletions
|
@ -118,7 +118,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun checkQrCodeLoginCapability(homeServerUrl: String) {
|
||||
private suspend fun checkQrCodeLoginCapability(config: HomeServerConnectionConfig) {
|
||||
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
||||
setState {
|
||||
copy(
|
||||
|
@ -133,10 +133,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
} else {
|
||||
viewModelScope.launch {
|
||||
// check if selected server supports MSC3882 first
|
||||
homeServerConnectionConfigFactory.create(homeServerUrl)?.let {
|
||||
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
|
||||
val canLoginWithQrCode = authenticationService.isQrLoginSupported(config)
|
||||
setState {
|
||||
copy(
|
||||
canLoginWithQrCode = canLoginWithQrCode
|
||||
|
@ -144,8 +142,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash()
|
||||
private val defaultHomeserverUrl = matrixOrgUrl
|
||||
|
@ -710,7 +706,6 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
||||
} else {
|
||||
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
||||
checkQrCodeLoginCapability(homeServerConnectionConfig.homeServerUri.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -769,6 +764,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(OnboardingViewEvents.OutdatedHomeserver)
|
||||
}
|
||||
|
||||
checkQrCodeLoginCapability(config)
|
||||
|
||||
when (trigger) {
|
||||
is OnboardingAction.HomeServerChange.SelectHomeServer -> {
|
||||
onHomeServerSelected(config, serverTypeOverride, authResult)
|
||||
|
|
Loading…
Reference in a new issue