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
@ -701,9 +701,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
private fun onAuthenticationStartError(error: Throwable, trigger: OnboardingAction.HomeServerChange) {
|
private fun onAuthenticationStartError(error: Throwable, trigger: OnboardingAction.HomeServerChange) {
|
||||||
when {
|
when {
|
||||||
error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post(
|
error.isHomeserverUnavailable() && applicationContext.inferNoConnectivity(sdkIntProvider) -> _viewEvents.post(OnboardingViewEvents.Failure(error))
|
||||||
OnboardingViewEvents.Failure(error)
|
isUnableToSelectServer(error, trigger) -> handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection))
|
||||||
)
|
|
||||||
deeplinkUrlIsUnavailable(error, trigger) -> _viewEvents.post(
|
deeplinkUrlIsUnavailable(error, trigger) -> _viewEvents.post(
|
||||||
OnboardingViewEvents.DeeplinkAuthenticationFailure(
|
OnboardingViewEvents.DeeplinkAuthenticationFailure(
|
||||||
retryAction = (trigger as OnboardingAction.HomeServerChange.SelectHomeServer).resetToDefaultUrl()
|
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() &&
|
private fun deeplinkUrlIsUnavailable(error: Throwable, trigger: OnboardingAction.HomeServerChange) = error.isHomeserverUnavailable() &&
|
||||||
loginConfig != null &&
|
loginConfig != null &&
|
||||||
trigger is OnboardingAction.HomeServerChange.SelectHomeServer
|
trigger is OnboardingAction.HomeServerChange.SelectHomeServer
|
||||||
@ -807,6 +809,8 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
return loginConfig?.homeServerUrl
|
return loginConfig?.homeServerUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getDefaultHomeserverUrl() = defaultHomeserverUrl
|
||||||
|
|
||||||
fun fetchSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
|
fun fetchSsoUrl(redirectUrl: String, deviceId: String?, provider: SsoIdentityProvider?): String? {
|
||||||
setState {
|
setState {
|
||||||
val authDescription = AuthenticationDescription.Register(provider.toAuthenticationType())
|
val authDescription = AuthenticationDescription.Register(provider.toAuthenticationType())
|
||||||
|
@ -86,7 +86,7 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (views.chooseServerInput.content().isEmpty()) {
|
if (views.chooseServerInput.content().isEmpty()) {
|
||||||
val userUrlInput = state.selectedHomeserver.userFacingUrl?.toReducedUrlKeepingSchemaIfInsecure()
|
val userUrlInput = state.selectedHomeserver.userFacingUrl?.toReducedUrlKeepingSchemaIfInsecure() ?: viewModel.getDefaultHomeserverUrl()
|
||||||
views.chooseServerInput.editText().setText(userUrlInput)
|
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.login.TextInputFormFragmentMode
|
||||||
import im.vector.app.features.onboarding.OnboardingAction
|
import im.vector.app.features.onboarding.OnboardingAction
|
||||||
import im.vector.app.features.onboarding.OnboardingActivity
|
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.OnboardingVariant
|
||||||
import im.vector.app.features.onboarding.OnboardingViewEvents
|
import im.vector.app.features.onboarding.OnboardingViewEvents
|
||||||
import im.vector.app.features.onboarding.OnboardingViewModel
|
import im.vector.app.features.onboarding.OnboardingViewModel
|
||||||
@ -213,7 +214,7 @@ class FtueAuthVariant(
|
|||||||
option = commonOption
|
option = commonOption
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
OnboardingViewEvents.OpenCombinedRegister -> openStartCombinedRegister()
|
OnboardingViewEvents.OpenCombinedRegister -> onStartCombinedRegister()
|
||||||
is OnboardingViewEvents.OnAccountCreated -> onAccountCreated()
|
is OnboardingViewEvents.OnAccountCreated -> onAccountCreated()
|
||||||
OnboardingViewEvents.OnAccountSignedIn -> onAccountSignedIn()
|
OnboardingViewEvents.OnAccountSignedIn -> onAccountSignedIn()
|
||||||
OnboardingViewEvents.OnChooseDisplayName -> onChooseDisplayName()
|
OnboardingViewEvents.OnChooseDisplayName -> onChooseDisplayName()
|
||||||
@ -229,21 +230,43 @@ class FtueAuthVariant(
|
|||||||
tag = FRAGMENT_EDIT_HOMESERVER_TAG
|
tag = FRAGMENT_EDIT_HOMESERVER_TAG
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
OnboardingViewEvents.OnHomeserverEdited -> supportFragmentManager.popBackStack(
|
OnboardingViewEvents.OnHomeserverEdited -> {
|
||||||
|
supportFragmentManager.popBackStack(
|
||||||
FRAGMENT_EDIT_HOMESERVER_TAG,
|
FRAGMENT_EDIT_HOMESERVER_TAG,
|
||||||
FragmentManager.POP_BACK_STACK_INCLUSIVE
|
FragmentManager.POP_BACK_STACK_INCLUSIVE
|
||||||
)
|
)
|
||||||
|
ensureEditServerBackstack()
|
||||||
|
}
|
||||||
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
OnboardingViewEvents.OpenCombinedLogin -> onStartCombinedLogin()
|
||||||
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
is OnboardingViewEvents.DeeplinkAuthenticationFailure -> onDeeplinkedHomeserverUnavailable(viewEvents)
|
||||||
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
OnboardingViewEvents.DisplayRegistrationFallback -> displayFallbackWebDialog()
|
||||||
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
is OnboardingViewEvents.DisplayRegistrationStage -> doStage(viewEvents.stage)
|
||||||
OnboardingViewEvents.DisplayStartRegistration -> when {
|
OnboardingViewEvents.DisplayStartRegistration -> when {
|
||||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> openStartCombinedRegister()
|
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> onStartCombinedRegister()
|
||||||
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
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) {
|
private fun onDeeplinkedHomeserverUnavailable(viewEvents: OnboardingViewEvents.DeeplinkAuthenticationFailure) {
|
||||||
showHomeserverUnavailableDialog(onboardingViewModel.getInitialHomeServerUrl().orEmpty()) {
|
showHomeserverUnavailableDialog(onboardingViewModel.getInitialHomeServerUrl().orEmpty()) {
|
||||||
onboardingViewModel.handle(OnboardingAction.ResetDeeplinkConfig)
|
onboardingViewModel.handle(OnboardingAction.ResetDeeplinkConfig)
|
||||||
@ -264,7 +287,7 @@ class FtueAuthVariant(
|
|||||||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java, allowStateLoss = true)
|
addRegistrationStageFragmentToBackstack(FtueAuthCombinedLoginFragment::class.java, allowStateLoss = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openStartCombinedRegister() {
|
private fun onStartCombinedRegister() {
|
||||||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java, allowStateLoss = true)
|
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java, allowStateLoss = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user