From 88df169f92c52e4f5b3bcf127ee203222d9ba242 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 31 Aug 2020 11:18:51 +0200 Subject: [PATCH] Fixed adjusting displayIndex when a bank gets deleted --- .../net/dankito/banking/ui/presenter/BankingPresenter.kt | 9 +++++++++ 1 file changed, 9 insertions(+) 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 93471c59..386daa9d 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 @@ -254,8 +254,17 @@ open class BankingPresenter( bankingClientsForAccounts.remove(customer) + val displayIndex = customer.displayIndex + persister.deleteAccount(customer, customers) + val sortedBanks = customers.sortedByDisplayIndex() + for (i in IntRange(displayIndex, sortedBanks.size - 1)) { + val bank = sortedBanks[i] + bank.displayIndex = i + accountUpdated(bank) + } + callAccountsChangedListeners() if (wasSelected || areAllAccountSelected) { // to update displayed account transactions as transactions of yet deleted accounts have to be removed