Collecting MessageLog
This commit is contained in:
parent
b518f4c0ee
commit
9c9d52f03e
|
@ -49,6 +49,8 @@ class BankingService(
|
||||||
|
|
||||||
private val modelService = BankingModelService()
|
private val modelService = BankingModelService()
|
||||||
|
|
||||||
|
private val messageLog = mutableListOf<MessageLogEntry>() // TODO: make thread safe
|
||||||
|
|
||||||
private val log by logger()
|
private val log by logger()
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,6 +158,9 @@ class BankingService(
|
||||||
fun getTransaction(transactionId: Long) = bankingRepository.getTransactionById(transactionId)
|
fun getTransaction(transactionId: Long) = bankingRepository.getTransactionById(transactionId)
|
||||||
|
|
||||||
|
|
||||||
|
fun getMessageLog() = messageLog.toList()
|
||||||
|
|
||||||
|
|
||||||
suspend fun findBanks(query: String): List<BankInfo> =
|
suspend fun findBanks(query: String): List<BankInfo> =
|
||||||
bankFinder.findBankByNameBicBankCodeOrCity(query, 25)
|
bankFinder.findBankByNameBicBankCodeOrCity(query, 25)
|
||||||
|
|
||||||
|
@ -170,6 +175,8 @@ class BankingService(
|
||||||
handleUnsuccessfulBankingClientResponse(BankingClientAction.AddAccount, bank.name, response)
|
handleUnsuccessfulBankingClientResponse(BankingClientAction.AddAccount, bank.name, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCommonBankingClientResponseValues(response)
|
||||||
|
|
||||||
return response.type == ResponseType.Success
|
return response.type == ResponseType.Success
|
||||||
} catch (e: Throwable) {
|
} 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)
|
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) {
|
private suspend fun updateAccountTransactions(bank: BankAccessEntity, bankAccount: BankAccountEntity? = null) {
|
||||||
try {
|
try {
|
||||||
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
val response = client.updateAccountTransactionsAsync(bank, bankAccount?.let { listOf(it) })
|
||||||
|
|
||||||
|
handleCommonBankingClientResponseValues(response)
|
||||||
|
|
||||||
if (response.type == ResponseType.Success && response.data != null) {
|
if (response.type == ResponseType.Success && response.data != null) {
|
||||||
handleSuccessfulUpdateAccountTransactionsResponse(bank, response.data!!)
|
handleSuccessfulUpdateAccountTransactionsResponse(bank, response.data!!)
|
||||||
} else {
|
} else {
|
||||||
|
@ -395,6 +405,8 @@ class BankingService(
|
||||||
paymentReference, instantTransfer
|
paymentReference, instantTransfer
|
||||||
))
|
))
|
||||||
|
|
||||||
|
handleCommonBankingClientResponseValues(response)
|
||||||
|
|
||||||
if (response.error != null) {
|
if (response.error != null) {
|
||||||
handleUnsuccessfulBankingClientResponse(BankingClientAction.TransferMoney, account.displayName, response)
|
handleUnsuccessfulBankingClientResponse(BankingClientAction.TransferMoney, account.displayName, response)
|
||||||
} else if (response.type == ResponseType.Success) {
|
} 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) {
|
private suspend fun updateOnChanges(uiSettings: UiSettings) {
|
||||||
updateOnChanges(uiSettings, uiSettings.transactionsGrouping)
|
updateOnChanges(uiSettings, uiSettings.transactionsGrouping)
|
||||||
|
|
Loading…
Reference in New Issue