mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-17 02:15:17 +08:00
extracting server selection branches to their own functions
This commit is contained in:
parent
690fda180c
commit
b8418f97dc
@ -649,20 +649,20 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
when (trigger) {
|
||||
is OnboardingAction.HomeServerChange.EditHomeServer -> {
|
||||
when (awaitState().onboardingFlow) {
|
||||
OnboardingFlow.SignUp -> internalRegisterAction(RegisterAction.StartRegistration) {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||
}
|
||||
OnboardingFlow.SignIn -> {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||
}
|
||||
else -> throw IllegalArgumentException("developer error")
|
||||
}
|
||||
}
|
||||
is OnboardingAction.HomeServerChange.SelectHomeServer -> {
|
||||
onHomeServerSelected(config, serverTypeOverride, authResult)
|
||||
}
|
||||
is OnboardingAction.HomeServerChange.EditHomeServer -> {
|
||||
onHomeServerEdited(config, serverTypeOverride, authResult)
|
||||
}
|
||||
else -> {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun onHomeServerSelected(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationResult) {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
if (authResult.selectedHomeserver.preferredLoginMode.supportsSignModeScreen()) {
|
||||
when (awaitState().onboardingFlow) {
|
||||
@ -686,10 +686,18 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
||||
private suspend fun onHomeServerEdited(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationResult) {
|
||||
when (awaitState().onboardingFlow) {
|
||||
OnboardingFlow.SignUp -> internalRegisterAction(RegisterAction.StartRegistration) {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||
}
|
||||
OnboardingFlow.SignIn -> {
|
||||
updateServerSelection(config, serverTypeOverride, authResult)
|
||||
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||
}
|
||||
else -> throw IllegalArgumentException("developer error")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user