From c4449024b78166bde2811070dd1f9f3446ba0ac7 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 30 May 2022 13:35:06 +0100 Subject: [PATCH] adding dedicated fail event in the legacy onboarding flow when the reset password new password is not set --- .../app/features/login/LoginViewModel.kt | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt index 4709fbbf7a3..e4b05789fb9 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt @@ -529,26 +529,34 @@ class LoginViewModel @AssistedInject constructor( } currentJob = viewModelScope.launch { - try { - val state = awaitState() - safeLoginWizard.resetPasswordMailConfirmed(state.resetPasswordNewPassword!!) - } catch (failure: Throwable) { + val state = awaitState() + + if (state.resetPasswordNewPassword == null) setState { copy( - asyncResetMailConfirmed = Fail(failure) + asyncResetPassword = Uninitialized, + asyncResetMailConfirmed = Fail(Throwable("Developer error - New password not set")) ) + } else { + try { + safeLoginWizard.resetPasswordMailConfirmed(state.resetPasswordNewPassword) + } catch (failure: Throwable) { + setState { + copy( + asyncResetMailConfirmed = Fail(failure) + ) + } + return@launch } - return@launch - } - setState { - copy( - asyncResetMailConfirmed = Success(Unit), - resetPasswordEmail = null, - resetPasswordNewPassword = null - ) + setState { + copy( + asyncResetMailConfirmed = Success(Unit), + resetPasswordEmail = null, + resetPasswordNewPassword = null + ) + } + _viewEvents.post(LoginViewEvents.OnResetPasswordMailConfirmationSuccess) } - - _viewEvents.post(LoginViewEvents.OnResetPasswordMailConfirmationSuccess) } } }