applying the manual reordering of the sign up stages only when matrix.org is selected
- lifts the logic up to the view model
This commit is contained in:
parent
15366f8d2a
commit
a893f5acdb
|
@ -0,0 +1 @@
|
||||||
|
FTUE - Overrides sign up flow ordering for matrix.org only
|
|
@ -42,6 +42,7 @@ import im.vector.app.features.login.ReAuthHelper
|
||||||
import im.vector.app.features.login.ServerType
|
import im.vector.app.features.login.ServerType
|
||||||
import im.vector.app.features.login.SignMode
|
import im.vector.app.features.login.SignMode
|
||||||
import im.vector.app.features.onboarding.StartAuthenticationFlowUseCase.StartAuthenticationResult
|
import im.vector.app.features.onboarding.StartAuthenticationFlowUseCase.StartAuthenticationResult
|
||||||
|
import im.vector.app.features.onboarding.ftueauth.FtueMissingRegistrationStagesComparator
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -289,9 +290,19 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emitFlowResultViewEvent(flowResult: FlowResult) {
|
private fun emitFlowResultViewEvent(flowResult: FlowResult) {
|
||||||
_viewEvents.post(OnboardingViewEvents.RegistrationFlowResult(flowResult, isRegistrationStarted))
|
withState { state ->
|
||||||
|
val orderedResult = when {
|
||||||
|
state.hasSelectedMatrixOrg() && vectorFeatures.isOnboardingCombinedRegisterEnabled() -> flowResult.overrideOrder()
|
||||||
|
else -> flowResult
|
||||||
|
}
|
||||||
|
_viewEvents.post(OnboardingViewEvents.RegistrationFlowResult(orderedResult, isRegistrationStarted))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun OnboardingViewState.hasSelectedMatrixOrg() = selectedHomeserver.userFacingUrl == matrixOrgUrl
|
||||||
|
|
||||||
|
private fun FlowResult.overrideOrder() = copy(missingStages = missingStages.sortedWith(FtueMissingRegistrationStagesComparator()))
|
||||||
|
|
||||||
private fun handleRegisterWith(action: OnboardingAction.Register) {
|
private fun handleRegisterWith(action: OnboardingAction.Register) {
|
||||||
reAuthHelper.data = action.password
|
reAuthHelper.data = action.password
|
||||||
handleRegisterAction(
|
handleRegisterAction(
|
||||||
|
|
|
@ -54,7 +54,6 @@ import im.vector.app.features.onboarding.OnboardingViewState
|
||||||
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthLegacyStyleTermsFragment
|
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthLegacyStyleTermsFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsFragment
|
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsFragment
|
||||||
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsLegacyStyleFragmentArgument
|
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsLegacyStyleFragmentArgument
|
||||||
import org.matrix.android.sdk.api.auth.registration.FlowResult
|
|
||||||
import org.matrix.android.sdk.api.auth.registration.Stage
|
import org.matrix.android.sdk.api.auth.registration.Stage
|
||||||
import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms
|
import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
|
@ -240,17 +239,12 @@ class FtueAuthVariant(
|
||||||
private fun onRegistrationFlow(viewEvents: OnboardingViewEvents.RegistrationFlowResult) {
|
private fun onRegistrationFlow(viewEvents: OnboardingViewEvents.RegistrationFlowResult) {
|
||||||
when {
|
when {
|
||||||
registrationShouldFallback(viewEvents) -> displayFallbackWebDialog()
|
registrationShouldFallback(viewEvents) -> displayFallbackWebDialog()
|
||||||
viewEvents.isRegistrationStarted -> handleRegistrationNavigation(viewEvents.flowResult.orderedStages())
|
viewEvents.isRegistrationStarted -> handleRegistrationNavigation(viewEvents.flowResult.missingStages)
|
||||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> openStartCombinedRegister()
|
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> openStartCombinedRegister()
|
||||||
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
else -> openAuthLoginFragmentWithTag(FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FlowResult.orderedStages() = when {
|
|
||||||
vectorFeatures.isOnboardingCombinedRegisterEnabled() -> missingStages.sortedWith(FtueMissingRegistrationStagesComparator())
|
|
||||||
else -> missingStages
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun openStartCombinedRegister() {
|
private fun openStartCombinedRegister() {
|
||||||
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java)
|
addRegistrationStageFragmentToBackstack(FtueAuthCombinedRegisterFragment::class.java)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue