Fixed that some clients need a response

This commit is contained in:
dankito 2020-09-30 04:50:54 +02:00
parent b7f9a2a5f7
commit 8a2750a21c
2 changed files with 14 additions and 12 deletions

View File

@ -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)
}
}

View File

@ -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 ?? "")."))
}
}
}
}