Collecting MessageLog
This commit is contained in:
parent
b518f4c0ee
commit
9c9d52f03e
|
@ -49,6 +49,8 @@ class BankingService(
|
|||
|
||||
private val modelService = BankingModelService()
|
||||
|
||||
private val messageLog = mutableListOf<MessageLogEntry>() // TODO: make thread safe
|
||||
|
||||
private val log by logger()
|
||||
|
||||
|
||||
|
@ -156,6 +158,9 @@ class BankingService(
|
|||
fun getTransaction(transactionId: Long) = bankingRepository.getTransactionById(transactionId)
|
||||
|
||||
|
||||
fun getMessageLog() = messageLog.toList()
|
||||
|
||||
|
||||
suspend fun findBanks(query: String): List<BankInfo> =
|
||||
bankFinder.findBankByNameBicBankCodeOrCity(query, 25)
|
||||
|
||||
|
@ -170,6 +175,8 @@ class BankingService(
|
|||
handleUnsuccessfulBankingClientResponse(BankingClientAction.AddAccount, bank.name, response)
|
||||
}
|
||||
|
||||
handleCommonBankingClientResponseValues(response)
|
||||
|
||||
return response.type == ResponseType.Success
|
||||
} catch (e: Throwable) {
|
||||
showAndLogError(ErroneousAction.AddAccount, "Could not add account for ${bank.name} $loginName", "Konto für ${bank.name} konnte nicht hinzugefügt werden", e)
|
||||
|
@ -225,6 +232,9 @@ class BankingService(
|
|||
private suspend fun updateAccountTransactions(bank: BankAccessEntity, bankAccount: BankAccountEntity? = null) {
|
||||
try {
|
||||
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
||||
|
||||
handleCommonBankingClientResponseValues(response)
|
||||
|
||||
if (response.type == ResponseType.Success && response.data != null) {
|
||||
handleSuccessfulUpdateAccountTransactionsResponse(bank, response.data!!)
|
||||
} else {
|
||||
|
@ -395,6 +405,8 @@ class BankingService(
|
|||
paymentReference, instantTransfer
|
||||
))
|
||||
|
||||
handleCommonBankingClientResponseValues(response)
|
||||
|
||||
if (response.error != null) {
|
||||
handleUnsuccessfulBankingClientResponse(BankingClientAction.TransferMoney, account.displayName, response)
|
||||
} else if (response.type == ResponseType.Success) {
|
||||
|
@ -417,6 +429,12 @@ class BankingService(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun handleCommonBankingClientResponseValues(response: Response<*>) {
|
||||
withContext(Dispatchers.Main) { // dispatch to Main as messageLog is not synchronized
|
||||
messageLog.addAll(response.messageLog)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private suspend fun updateOnChanges(uiSettings: UiSettings) {
|
||||
updateOnChanges(uiSettings, uiSettings.transactionsGrouping)
|
||||
|
|
Loading…
Reference in New Issue