From 83e8b7b882efbdb15272c5c4525a3863fc83245c Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 16 Nov 2020 22:16:12 +0100 Subject: [PATCH] Implemented adding message log of accounts that could not be added to message log --- .../banking/ui/presenter/BankingPresenter.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt index ac5d1118..cbeca2f9 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -87,6 +87,8 @@ open class BankingPresenter( protected val bankingClientsForBanks = mutableMapOf() + protected val messageLogsOfFailedAccountAdditions = mutableListOf() + protected var _selectedAccounts = mutableListOf() protected var selectedAccountType = SelectedAccountType.AllAccounts @@ -189,6 +191,9 @@ open class BankingPresenter( log.error(e) { "Could not save successfully added bank" } } } + else { + messageLogsOfFailedAccountAdditions.addAll(newClient.messageLogWithoutSensitiveData) + } callback(response) } @@ -777,11 +782,17 @@ open class BankingPresenter( } - open fun getMessageLogForAccounts(banks: List): List { - val logEntries = banks.flatMap { - getBankingClientForBank(it)?.messageLogWithoutSensitiveData ?: listOf() + open fun getMessageLogForAccounts(banks: List, includeFailedAccountAdditions: Boolean = true): List { + val logEntries = mutableListOf() + + if (includeFailedAccountAdditions) { + logEntries.addAll(messageLogsOfFailedAccountAdditions) } + logEntries.addAll(banks.flatMap { + getBankingClientForBank(it)?.messageLogWithoutSensitiveData ?: listOf() + }) + return logEntries.map { entry -> MessageLogEntryDateFormatter.format(entry.time) + " " + entry.bank.bankCode + " " + entry.message }