From f265724a3ccf5de77217cb98c759b48c621cbd8f Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 13 Nov 2019 19:20:03 +0100 Subject: [PATCH] Login sso: handle failure --- .../java/im/vector/riotx/features/login/LoginViewModel.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt index 4c72d041d6..a0a7258e2a 100644 --- a/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/LoginViewModel.kt @@ -134,6 +134,10 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi override fun onSuccess(data: Session) { onSessionCreated(data) } + + override fun onFailure(failure: Throwable) = setState { + copy(asyncLoginAction = Fail(failure)) + } }) } } @@ -150,7 +154,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi // Do not retry if we already have flows for this config -> causes infinite focus loop if (newConfig?.homeServerUri?.toString() == homeServerConnectionConfig?.homeServerUri?.toString() - && state.asyncHomeServerLoginFlowRequest is Success) return@withState + && state.asyncHomeServerLoginFlowRequest is Success) return@withState currentTask?.cancel() homeServerConnectionConfig = newConfig