mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +03:00
extracting server selection branches to their own functions
This commit is contained in:
parent
690fda180c
commit
b8418f97dc
1 changed files with 43 additions and 35 deletions
|
@ -649,42 +649,11 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
when (trigger) {
|
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 -> {
|
is OnboardingAction.HomeServerChange.SelectHomeServer -> {
|
||||||
updateServerSelection(config, serverTypeOverride, authResult)
|
onHomeServerSelected(config, serverTypeOverride, authResult)
|
||||||
if (authResult.selectedHomeserver.preferredLoginMode.supportsSignModeScreen()) {
|
}
|
||||||
when (awaitState().onboardingFlow) {
|
is OnboardingAction.HomeServerChange.EditHomeServer -> {
|
||||||
OnboardingFlow.SignIn -> {
|
onHomeServerEdited(config, serverTypeOverride, authResult)
|
||||||
updateSignMode(SignMode.SignIn)
|
|
||||||
when (vectorFeatures.isOnboardingCombinedLoginEnabled()) {
|
|
||||||
true -> _viewEvents.post(OnboardingViewEvents.OpenCombinedLogin)
|
|
||||||
false -> _viewEvents.post(OnboardingViewEvents.OnSignModeSelected(SignMode.SignIn))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OnboardingFlow.SignUp -> {
|
|
||||||
updateSignMode(SignMode.SignUp)
|
|
||||||
internalRegisterAction(RegisterAction.StartRegistration, ::emitFlowResultViewEvent)
|
|
||||||
}
|
|
||||||
OnboardingFlow.SignInSignUp,
|
|
||||||
null -> {
|
|
||||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
updateServerSelection(config, serverTypeOverride, authResult)
|
updateServerSelection(config, serverTypeOverride, authResult)
|
||||||
|
@ -693,6 +662,45 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun onHomeServerSelected(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationResult) {
|
||||||
|
updateServerSelection(config, serverTypeOverride, authResult)
|
||||||
|
if (authResult.selectedHomeserver.preferredLoginMode.supportsSignModeScreen()) {
|
||||||
|
when (awaitState().onboardingFlow) {
|
||||||
|
OnboardingFlow.SignIn -> {
|
||||||
|
updateSignMode(SignMode.SignIn)
|
||||||
|
when (vectorFeatures.isOnboardingCombinedLoginEnabled()) {
|
||||||
|
true -> _viewEvents.post(OnboardingViewEvents.OpenCombinedLogin)
|
||||||
|
false -> _viewEvents.post(OnboardingViewEvents.OnSignModeSelected(SignMode.SignIn))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OnboardingFlow.SignUp -> {
|
||||||
|
updateSignMode(SignMode.SignUp)
|
||||||
|
internalRegisterAction(RegisterAction.StartRegistration, ::emitFlowResultViewEvent)
|
||||||
|
}
|
||||||
|
OnboardingFlow.SignInSignUp,
|
||||||
|
null -> {
|
||||||
|
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_viewEvents.post(OnboardingViewEvents.OnLoginFlowRetrieved)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.OnHomeserverEdited)
|
||||||
|
}
|
||||||
|
OnboardingFlow.SignIn -> {
|
||||||
|
updateServerSelection(config, serverTypeOverride, authResult)
|
||||||
|
_viewEvents.post(OnboardingViewEvents.OnHomeserverEdited)
|
||||||
|
}
|
||||||
|
else -> throw IllegalArgumentException("developer error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateServerSelection(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationResult) {
|
private fun updateServerSelection(config: HomeServerConnectionConfig, serverTypeOverride: ServerType?, authResult: StartAuthenticationResult) {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
|
Loading…
Reference in a new issue