NTP-3825 | PS | fix for multi payment attempt for NaviUpi from NPS (#12580)

This commit is contained in:
Prakhar Saxena
2024-09-20 18:31:53 +05:30
committed by GitHub
parent f98ffa3a30
commit 9237a9f429

View File

@@ -29,6 +29,7 @@ import com.navi.pay.onboarding.account.linked.model.network.CheckBalanceResponse
import com.navi.pay.onboarding.account.linked.model.network.LinkedAccountsRequest
import com.navi.pay.onboarding.account.linked.model.network.LinkedAccountsResponse
import javax.inject.Inject
import kotlinx.coroutines.flow.distinctUntilChanged
class AccountsRepository
@Inject
@@ -81,7 +82,14 @@ constructor(
accountDao.insertAll(accountEntities = accountEntities)
fun getAllAccountByStatusAsFlow(status: AccountStatus) =
accountDao.getAllAccountByStatusAsFlow(status = status)
accountDao.getAllAccountByStatusAsFlow(status = status).distinctUntilChanged { old, new ->
if (old.size != new.size) {
return@distinctUntilChanged false
}
val newAccountsSet = new.map { it.copy(id = 0) }.toSet()
old.all { oldAccount -> newAccountsSet.contains(oldAccount.copy(id = 0)) }
}
suspend fun deleteAllAccounts() = accountDao.deleteAll()