updating the server selection on non Edit/Select events
- such as deeplinks - extracts a common function
This commit is contained in:
parent
ee693b5ad4
commit
a34b424b7b
|
@ -625,32 +625,20 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(OnboardingViewEvents.OutdatedHomeserver)
|
||||
}
|
||||
|
||||
val state = awaitState()
|
||||
|
||||
when (trigger) {
|
||||
is OnboardingAction.HomeServerChange.EditHomeServer -> {
|
||||
when (state.onboardingFlow) {
|
||||
when (awaitState().onboardingFlow) {
|
||||
OnboardingFlow.SignUp -> internalRegisterAction(RegisterAction.StartRegistration) { _ ->
|
||||
setState {
|
||||
copy(
|
||||
serverType = alignServerTypeAfterSubmission(config, serverTypeOverride),
|
||||
selectedHomeserver = authResult.selectedHomeserver,
|
||||
)
|
||||
}
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||
}
|
||||
else -> throw IllegalArgumentException("developer error")
|
||||
}
|
||||
}
|
||||
is OnboardingAction.HomeServerChange.SelectHomeServer -> {
|
||||
setState {
|
||||
copy(
|
||||
serverType = alignServerTypeAfterSubmission(config, serverTypeOverride),
|
||||
selectedHomeserver = authResult.selectedHomeserver,
|
||||
)
|
||||
}
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
if (authResult.selectedHomeserver.preferredLoginMode.supportsSignModeScreen()) {
|
||||
when (state.onboardingFlow) {
|
||||
when (awaitState().onboardingFlow) {
|
||||
OnboardingFlow.SignIn -> internalRegisterAction(RegisterAction.StartRegistration, ::emitFlowResultViewEvent)
|
||||
OnboardingFlow.SignUp -> internalRegisterAction(RegisterAction.StartRegistration, ::emitFlowResultViewEvent)
|
||||
OnboardingFlow.SignInSignUp,
|
||||
|
@ -662,7 +650,19 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
}
|
||||
}
|
||||
else -> _viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
else -> {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateServerSelection(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationFlowUseCase.StartAuthenticationResult) {
|
||||
setState {
|
||||
copy(
|
||||
serverType = alignServerTypeAfterSubmission(config, serverTypeOverride),
|
||||
selectedHomeserver = authResult.selectedHomeserver,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue