Retrieving account transactions in parallel not serially
This commit is contained in:
parent
54ca55e2f9
commit
e0e150e53a
|
@ -207,29 +207,31 @@ class BankingService(
|
|||
|
||||
|
||||
suspend fun updateAccountTransactions() {
|
||||
val selectedAccount = uiState.transactionsFilter.value.selectedAccount
|
||||
if (selectedAccount != null) {
|
||||
updateAccountTransactions(selectedAccount.bank, selectedAccount.bankAccount)
|
||||
} else {
|
||||
getCurrentUiBanksList().forEach { bank ->
|
||||
// TODO: when implementing automatic account transactions update, filter out accounts with includeInAutomaticAccountsUpdate == false
|
||||
updateAccountTransactions(bank)
|
||||
withContext(Dispatchers.IOorDefault) {
|
||||
val selectedAccount = uiState.transactionsFilter.value.selectedAccount
|
||||
if (selectedAccount != null) {
|
||||
updateAccountTransactions(selectedAccount.bank, selectedAccount.bankAccount)
|
||||
} else {
|
||||
getCurrentUiBanksList().forEach { bank ->
|
||||
launch {
|
||||
// TODO: when implementing automatic account transactions update, filter out accounts with includeInAutomaticAccountsUpdate == false
|
||||
updateAccountTransactions(bank)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateAccountTransactions(bank: BankAccessEntity, bankAccount: BankAccountEntity? = null) {
|
||||
withContext(Dispatchers.IOorDefault) {
|
||||
try {
|
||||
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
||||
if (response.type == ResponseType.Success && response.data != null) {
|
||||
handleSuccessfulUpdateAccountTransactionsResponse(bank, response.data!!)
|
||||
} else {
|
||||
handleUnsuccessfulBankingClientResponse(BankingClientAction.UpdateAccountTransactions, bankAccount?.displayName ?: bank.displayName, response)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
log.error(e) { "Could not update account transactions for $bank" }
|
||||
try {
|
||||
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
||||
if (response.type == ResponseType.Success && response.data != null) {
|
||||
handleSuccessfulUpdateAccountTransactionsResponse(bank, response.data!!)
|
||||
} else {
|
||||
handleUnsuccessfulBankingClientResponse(BankingClientAction.UpdateAccountTransactions, bankAccount?.displayName ?: bank.displayName, response)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
log.error(e) { "Could not update account transactions for $bank" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue