mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
SoftLogout: also handle Unsupported mode
This commit is contained in:
parent
1de85daad9
commit
12d54140e5
3 changed files with 24 additions and 15 deletions
|
@ -110,18 +110,24 @@ class SoftLogoutController @Inject constructor(
|
|||
errorText((state.asyncLoginAction as? Fail)?.error?.let { errorFormatter.toHumanReadable(it) })
|
||||
passwordRevealClickListener { listener?.revealPasswordClicked() }
|
||||
forgetPasswordClickListener { listener?.forgetPasswordClicked() }
|
||||
submitClickListener { password -> listener?.submit(password) }
|
||||
submitClickListener { password -> listener?.signinSubmit(password) }
|
||||
}
|
||||
}
|
||||
LoginMode.Sso -> {
|
||||
loginCenterButtonItem {
|
||||
id("sso")
|
||||
text(stringProvider.getString(R.string.login_signin_sso))
|
||||
listener { listener?.ssoSubmit() }
|
||||
listener { listener?.signinFallbackSubmit() }
|
||||
}
|
||||
}
|
||||
LoginMode.Unsupported -> {
|
||||
loginCenterButtonItem {
|
||||
id("fallback")
|
||||
text(stringProvider.getString(R.string.login_signin))
|
||||
listener { listener?.signinFallbackSubmit() }
|
||||
}
|
||||
}
|
||||
LoginMode.Unknown -> Unit // Should not happen
|
||||
LoginMode.Unsupported -> Unit // Should not happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +152,8 @@ class SoftLogoutController @Inject constructor(
|
|||
interface Listener {
|
||||
fun retry()
|
||||
fun passwordEdited(password: String)
|
||||
fun submit(password: String)
|
||||
fun ssoSubmit()
|
||||
fun signinSubmit(password: String)
|
||||
fun signinFallbackSubmit()
|
||||
fun clearData()
|
||||
fun forgetPasswordClicked()
|
||||
fun revealPasswordClicked()
|
||||
|
|
|
@ -59,13 +59,17 @@ class SoftLogoutFragment @Inject constructor(
|
|||
softLogoutViewModel.subscribe(this) { softLogoutViewState ->
|
||||
softLogoutController.update(softLogoutViewState)
|
||||
|
||||
if (softLogoutViewState.asyncHomeServerLoginFlowRequest.invoke() == LoginMode.Sso) {
|
||||
// Prepare the loginViewModel for a SSO recovery
|
||||
when (softLogoutViewState.asyncHomeServerLoginFlowRequest.invoke()) {
|
||||
LoginMode.Sso,
|
||||
LoginMode.Unsupported -> {
|
||||
// Prepare the loginViewModel for a SSO/login fallback recovery
|
||||
loginViewModel.handle(LoginAction.SetupSsoForSessionRecovery(
|
||||
softLogoutViewState.homeServerUrl,
|
||||
softLogoutViewState.deviceId
|
||||
))
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,12 +92,12 @@ class SoftLogoutFragment @Inject constructor(
|
|||
softLogoutViewModel.handle(SoftLogoutAction.PasswordChanged(password))
|
||||
}
|
||||
|
||||
override fun submit(password: String) {
|
||||
override fun signinSubmit(password: String) {
|
||||
cleanupUi()
|
||||
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(password))
|
||||
}
|
||||
|
||||
override fun ssoSubmit() {
|
||||
override fun signinFallbackSubmit() {
|
||||
loginSharedActionViewModel.post(LoginNavigation.OnSignModeSelected)
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,7 @@ class SoftLogoutViewModel @AssistedInject constructor(
|
|||
else -> LoginMode.Unsupported
|
||||
}
|
||||
|
||||
if ((loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported)
|
||||
|| loginMode == LoginMode.Unsupported) {
|
||||
if (loginMode == LoginMode.Password && !data.isLoginAndRegistrationSupported) {
|
||||
notSupported()
|
||||
} else {
|
||||
setState {
|
||||
|
|
Loading…
Reference in a new issue