Skip to content

Commit

Permalink
adding dedicated fail event in the legacy onboarding flow when the re…
Browse files Browse the repository at this point in the history
…set password new password is not set
  • Loading branch information
ouchadam committed May 30, 2022
1 parent 35cc0a7 commit c444902
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit c444902

Please sign in to comment.