From 8a2750a21c0f7c3ba7b9d11df5f07e96c3ce20e9 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 30 Sep 2020 04:50:54 +0200 Subject: [PATCH] Fixed that some clients need a response --- .../banking/ui/presenter/BankingPresenter.kt | 12 ++++++------ .../ui/dialogs/AccountTransactionsDialog.swift | 14 ++++++++------ 2 files changed, 14 insertions(+), 12 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 2fe350c0..195d198e 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 @@ -348,18 +348,18 @@ open class BankingPresenter( updateAllAccountsTransactionsAsync() } - open fun updateAllAccountsTransactionsAsync(done: (() -> Unit)? = null) { + open fun updateAllAccountsTransactionsAsync(callback: ((GetTransactionsResponse?) -> Unit)? = null) { val accountsToUpdate = allAccounts.filter { considerAccountInAutomaticUpdates(it) } if (accountsToUpdate.isNotEmpty()) { - updateAccountsTransactionsAsync(accountsToUpdate, true) { done?.invoke() } + updateAccountsTransactionsAsync(accountsToUpdate, true, callback) } else if (allAccounts.isNotEmpty()) { - done?.invoke() + callback?.invoke(null) } } - open fun updateSelectedAccountsTransactionsAsync(done: (() -> Unit)? = null) { + open fun updateSelectedAccountsTransactionsAsync(done: ((GetTransactionsResponse?) -> Unit)? = null) { var accountsToUpdate = selectedAccounts.filter { considerAccountInAutomaticUpdates(it) } if (accountsToUpdate.isEmpty() && (selectedAccountType == SelectedAccountType.SingleAccount || (selectedAccountType == SelectedAccountType.SingleBank && selectedAccounts.size == 1))) { @@ -367,10 +367,10 @@ open class BankingPresenter( } if (accountsToUpdate.isNotEmpty()) { - updateAccountsTransactionsAsync(accountsToUpdate, false) { done?.invoke() } + updateAccountsTransactionsAsync(accountsToUpdate, false, done) } else if (allAccounts.isNotEmpty()) { - done?.invoke() + done?.invoke(null) } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift index b8a2ce1f..a3581bee 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift @@ -206,12 +206,14 @@ struct AccountTransactionsDialog: View { self.balanceOfAllTransactions = self.presenter.balanceOfSelectedAccounts - if response.successful { - self.filterTransactions(self.searchText) - } - else if response.userCancelledAction == false { - if let failedAccount = getAccountThatFailed(response) { - self.errorMessage = Message(title: Text("Could not fetch latest transactions"), message: Text("Could not fetch latest transactions for \(failedAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "").")) + if let response = response { + if response.successful { + self.filterTransactions(self.searchText) + } + else if response.userCancelledAction == false { + if let failedAccount = getAccountThatFailed(response) { + self.errorMessage = Message(title: Text("Could not fetch latest transactions"), message: Text("Could not fetch latest transactions for \(failedAccount.displayName). Error message from your bank: \(response.errorToShowToUser ?? "").")) + } } } }