Avoid long lines

This commit is contained in:
Benoit Marty 2021-02-18 16:14:02 +01:00
parent dea76fd81b
commit b9f5863b53
2 changed files with 46 additions and 52 deletions

View File

@ -759,7 +759,7 @@ class LoginViewModel @AssistedInject constructor(
) )
} }
try { val data = try {
authenticationService.getLoginFlow(homeServerConnectionConfig) authenticationService.getLoginFlow(homeServerConnectionConfig)
} catch (failure: Throwable) { } catch (failure: Throwable) {
_viewEvents.post(LoginViewEvents.Failure(failure)) _viewEvents.post(LoginViewEvents.Failure(failure))
@ -772,13 +772,12 @@ class LoginViewModel @AssistedInject constructor(
} }
null null
} }
?.let { data ->
if (data is LoginFlowResult.Success) {
// Valid Homeserver, add it to the history. // Valid Homeserver, add it to the history.
// Note: we add what the user has input, data.homeServerUrl can be different // Note: we add what the user has input, data.homeServerUrl can be different
rememberHomeServer(homeServerConnectionConfig.homeServerUri.toString()) rememberHomeServer(homeServerConnectionConfig.homeServerUri.toString())
when (data) {
is LoginFlowResult.Success -> {
val loginMode = when { val loginMode = when {
// SSO login is taken first // SSO login is taken first
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
@ -805,8 +804,6 @@ class LoginViewModel @AssistedInject constructor(
} }
} }
} }
}
}
fun getInitialHomeServerUrl(): String? { fun getInitialHomeServerUrl(): String? {
return loginConfig?.homeServerUrl return loginConfig?.homeServerUrl

View File

@ -89,7 +89,7 @@ class SoftLogoutViewModel @AssistedInject constructor(
) )
} }
try { val data = try {
authenticationService.getLoginFlowOfSession(session.sessionId) authenticationService.getLoginFlowOfSession(session.sessionId)
} catch (failure: Throwable) { } catch (failure: Throwable) {
setState { setState {
@ -99,9 +99,8 @@ class SoftLogoutViewModel @AssistedInject constructor(
} }
null null
} }
?.let { data ->
when (data) { if (data is LoginFlowResult.Success) {
is LoginFlowResult.Success -> {
val loginMode = when { val loginMode = when {
// SSO login is taken first // SSO login is taken first
data.supportedLoginTypes.contains(LoginFlowTypes.SSO) data.supportedLoginTypes.contains(LoginFlowTypes.SSO)
@ -119,8 +118,6 @@ class SoftLogoutViewModel @AssistedInject constructor(
} }
} }
} }
}
}
override fun handle(action: SoftLogoutAction) { override fun handle(action: SoftLogoutAction) {
when (action) { when (action) {