From 6467964305a650a8b0c23cb84e859036f68e01c5 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 13 Sep 2020 00:01:48 +0200 Subject: [PATCH] Fixed calling accountsChangedListeners on changes, e.g. when bank displayName or bank displayIndex changed --- .../banking/ui/presenter/BankingPresenter.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 221f3125..c8f89f2c 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 @@ -393,16 +393,22 @@ open class BankingPresenter constructor( open fun accountDisplayIndexUpdated(account: TypedCustomer) { persistAccount(account) + + callAccountsChangedListeners(account) } open fun accountUpdated(bank: TypedCustomer) { persistAccount(bank) + callAccountsChangedListeners(bank) + getBankingClientForAccount(bank)?.dataChanged(bank) } open fun accountUpdated(account: TypedBankAccount) { persistAccount(account.customer) + + callAccountsChangedListeners(account.customer as TypedCustomer) } protected open fun persistAccount(customer: ICustomer<*, *>) { @@ -731,7 +737,15 @@ open class BankingPresenter constructor( } protected open fun callAccountsChangedListeners() { - val accounts = this.customers + val accounts = ArrayList(this.customers) + + ArrayList(accountsChangedListeners).forEach { + it(accounts) // TODO: use RxJava for this + } + } + + protected open fun callAccountsChangedListeners(account: TypedCustomer) { + val accounts = ArrayList(listOf(account)) ArrayList(accountsChangedListeners).forEach { it(accounts) // TODO: use RxJava for this