NTP-11104 | Shiv Natani | PayeeEntity Update in Send Money Vm (#13510)

This commit is contained in:
Shiv Natani
2024-11-07 19:48:01 +05:30
committed by GitHub
parent 52766132f0
commit 3aa989b1b7

View File

@@ -1737,13 +1737,12 @@ constructor(
}
}
internal fun init(isActivityRecreated: Boolean, payeeEntity: PayeeEntity? = null) {
internal fun init(isActivityRecreated: Boolean) {
viewModelScope.launch(coroutineDispatcherProvider.io) {
val vpaValidationAsyncResult = async { executeVpaValidation() }
linkedAccountsUseCase.execute(includeAllDetails = true).collect { linkedAccounts ->
handleLinkedAccounts(
payeeEntity = payeeEntity,
linkedAccounts = linkedAccounts,
vpaValidationAsyncResult = vpaValidationAsyncResult
)
@@ -1759,12 +1758,22 @@ constructor(
onCallBack: ((status: PMSSendMoneyStatus) -> Unit)? = null
) {
viewModelScope.launch(coroutineDispatcherProvider.io) {
// For PMS case payeeEntity is updated here
payeeEntity?.let {
updatePayeeEntity(it)
if (it.amount.isNotNullAndNotEmpty()) {
updatePaymentAmount(
TextFieldValue(it.amount, selection = TextRange(it.amount.length))
)
}
}
val vpaValidationAsyncResult = async { executeVpaValidation() }
linkedAccountsUseCase.execute(includeAllDetails = true).first { linkedAccounts ->
onCallBack?.let { pmsPostMPINCallBack = onCallBack }
handleLinkedAccounts(
payeeEntity = payeeEntity,
linkedAccounts = linkedAccounts,
vpaValidationAsyncResult = vpaValidationAsyncResult
)
@@ -1791,19 +1800,9 @@ constructor(
}
private suspend fun handleLinkedAccounts(
payeeEntity: PayeeEntity? = null,
linkedAccounts: List<LinkedAccountEntity>,
vpaValidationAsyncResult: Deferred<Boolean>
) {
payeeEntity?.let {
updatePayeeEntity(it)
if (it.amount.isNotNullAndNotEmpty()) {
updatePaymentAmount(
TextFieldValue(it.amount, selection = TextRange(it.amount.length))
)
}
}
val vpaValidationResult = vpaValidationAsyncResult.await()
if (!vpaValidationResult) { // Cannot proceed to next step