mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
redirecting to the edit server screen when attempting to select the initial homeserver choice and it fails
This commit is contained in:
parent
0be46adfda
commit
cdf75be0ec
3 changed files with 38 additions and 11 deletions
|
@ -701,9 +701,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
|
||||
private fun onAuthenticationStartError(error: Throwable, trigger: OnboardingAction.HomeServerChange) {
|
||||
when {
|
||||
error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post(
|
||||
OnboardingViewEvents.Failure(error)
|
||||
)
|
||||
error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post(OnboardingViewEvents.Failure(error))
|
||||
isUnableToSelectServer(error, trigger) -> handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection))
|
||||
deeplinkUrlIsUnavailable(error, trigger) -> _viewEvents.post(
|
||||
OnboardingViewEvents.DeeplinkAuthenticationFailure(
|
||||
retryAction = (trigger as OnboardingAction.HomeServerChange.SelectHomeServer).resetToDefaultUrl()
|
||||
|
@ -716,6 +715,9 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun isUnableToSelectServer(error: Throwable, trigger: OnboardingAction.HomeServerChange) =
|
||||
trigger is OnboardingAction.HomeServerChange.SelectHomeServer && error.isHomeserverUnavailable()
|
||||
|
||||
private fun deeplinkUrlIsUnavailable(error: Throwable, trigger: OnboardingAction.HomeServerChange) = error.isHomeserverUnavailable() &&
|
||||
loginConfig != null &&
|
||||
trigger is OnboardingAction.HomeServerChange.SelectHomeServer
|
||||
|
@ -807,6 +809,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
return loginConfig?.homeServerUrl
|
||||
}
|
||||
|
||||
fun getDefaultHomeserverUrl() = defaultHomeserverUrl
|
||||
|
||||
fun fetchSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
|
||||
setState {
|
||||
val authDescription = AuthenticationDescription.Register(provider.toAuthenticationType())
|
||||
|
|
|
@ -86,7 +86,7 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
|
|||
)
|
||||
|
||||
if (views.chooseServerInput.content().isEmpty()) {
|
||||
val userUrlInput = state.selectedHomeserver.userFacingUrl?.toReducedUrlKeepingSchemaIfInsecure()
|
||||
val userUrlInput = state.selectedHomeserver.userFacingUrl?.toReducedUrlKeepingSchemaIfInsecure() ?: viewModel.getDefaultHomeserverUrl()
|
||||
views.chooseServerInput.editText().setText(userUrlInput)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import im.vector.app.features.login.SignMode
|
|||
import im.vector.app.features.login.TextInputFormFragmentMode
|
||||
import im.vector.app.features.onboarding.OnboardingAction
|
||||
import im.vector.app.features.onboarding.OnboardingActivity
|
||||
import im.vector.app.features.onboarding.OnboardingFlow
|
||||
import im.vector.app.features.onboarding.OnboardingVariant
|
||||
import im.vector.app.features.onboarding.OnboardingViewEvents
|
||||
import im.vector.app.features.onboarding.OnboardingViewModel
|
||||
|
@ -213,7 +214,7 @@ class FtueAuthVariant(
|
|||
option = commonOption
|
||||
)
|
||||
}
|
||||
OnboardingViewEvents.OpenCombinedRegister -> openStartCombinedRegister()
|
||||
OnboardingViewEvents.OpenCombinedRegister -> onStartCombinedRegister()
|
||||
is OnboardingViewEvents.OnAccountCreated -> onAccountCreated()
|
||||
OnboardingViewEvents.OnAccountSignedIn -> onAccountSignedIn()
|
||||
OnboardingViewEvents.OnChooseDisplayName -> onChooseDisplayName()
|
||||
|
@ -229,21 +230,43 @@ class FtueAuthVariant(
|
|||
tag = FRAGMENT_EDIT_HOMESERVER_TAG
|
||||
)
|
||||
}
|
||||
OnboardingViewEvents.OnHomeserverEdited -> supportFragmentManager.popBackStack(
|
||||
FRAGMENT_EDIT_HOMESERVER_TAG,
|
||||
FragmentManager.POP_BACK_STACK_INCLUSIVE
|
||||
)
|
||||
OnboardingViewEvents.OnHomeserverEdited -> {
|
||||
supportFragmentManager.popBackStack(
|
||||
FRAGMENT_EDIT_HOMESERVER_TAG,
|
||||
FragmentManager.POP_BACK_STACK_INCLUSIVE
|
||||
)
|
||||
ensureEditServerBackstack()
|
||||
}
|
||||
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
||||
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
||||
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
||||
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
||||
OnboardingViewEvents.DisplayStartRegistration -> when {
|
||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> openStartCombinedRegister()
|
||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> onStartCombinedRegister()
|
||||
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ensureEditServerBackstack() {
|
||||
when (activity.supportFragmentManager.findFragmentById(views.loginFragmentContainer.id)) {
|
||||
is FtueAuthCombinedLoginFragment,
|
||||
is FtueAuthCombinedRegisterFragment -> {
|
||||
// do nothing
|
||||
}
|
||||
else -> {
|
||||
withState(onboardingViewModel) { state ->
|
||||
when (state.onboardingFlow) {
|
||||
OnboardingFlow.SignIn -> onStartCombinedLogin()
|
||||
OnboardingFlow.SignUp -> onStartCombinedRegister()
|
||||
OnboardingFlow.SignInSignUp,
|
||||
null -> error("${state.onboardingFlow} does not support editing server url")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onDeeplinkedHomeserverUnavailable(viewEvents: OnboardingViewEvents.DeeplinkAuthenticationFailure) {
|
||||
showHomeserverUnavailableDialog(onboardingViewModel.getInitialHomeServerUrl().orEmpty()) {
|
||||
onboardingViewModel.handle(OnboardingAction.ResetDeeplinkConfig)
|
||||
|
@ -264,7 +287,7 @@ class FtueAuthVariant(
|
|||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java, allowStateLoss = true)
|
||||
}
|
||||
|
||||
private fun openStartCombinedRegister() {
|
||||
private fun onStartCombinedRegister() {
|
||||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java, allowStateLoss = true)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue