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() updateAllAccountsTransactionsAsync()
} }
open fun updateAllAccountsTransactionsAsync(done: (() -> Unit)? = null) { open fun updateAllAccountsTransactionsAsync(callback: ((GetTransactionsResponse?) -> Unit)? = null) {
val accountsToUpdate = allAccounts.filter { considerAccountInAutomaticUpdates(it) } val accountsToUpdate = allAccounts.filter { considerAccountInAutomaticUpdates(it) }
if (accountsToUpdate.isNotEmpty()) { if (accountsToUpdate.isNotEmpty()) {
updateAccountsTransactionsAsync(accountsToUpdate, true) { done?.invoke() } updateAccountsTransactionsAsync(accountsToUpdate, true, callback)
} }
else if (allAccounts.isNotEmpty()) { 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) } var accountsToUpdate = selectedAccounts.filter { considerAccountInAutomaticUpdates(it) }
if (accountsToUpdate.isEmpty() && (selectedAccountType == SelectedAccountType.SingleAccount if (accountsToUpdate.isEmpty() && (selectedAccountType == SelectedAccountType.SingleAccount
|| (selectedAccountType == SelectedAccountType.SingleBank && selectedAccounts.size == 1))) { || (selectedAccountType == SelectedAccountType.SingleBank && selectedAccounts.size == 1))) {
@ -367,10 +367,10 @@ open class BankingPresenter(
} }
if (accountsToUpdate.isNotEmpty()) { if (accountsToUpdate.isNotEmpty()) {
updateAccountsTransactionsAsync(accountsToUpdate, false) { done?.invoke() } updateAccountsTransactionsAsync(accountsToUpdate, false, done)
} }
else if (allAccounts.isNotEmpty()) { else if (allAccounts.isNotEmpty()) {
done?.invoke() done?.invoke(null)
} }
} }

View File

@ -206,6 +206,7 @@ struct AccountTransactionsDialog: View {
self.balanceOfAllTransactions = self.presenter.balanceOfSelectedAccounts self.balanceOfAllTransactions = self.presenter.balanceOfSelectedAccounts
if let response = response {
if response.successful { if response.successful {
self.filterTransactions(self.searchText) self.filterTransactions(self.searchText)
} }
@ -216,6 +217,7 @@ struct AccountTransactionsDialog: View {
} }
} }
} }
}
private func fetchTransactions() { private func fetchTransactions() {
presenter.fetchTransactionsOfSelectedAccounts(callback: self.handleGetTransactionsResult) presenter.fetchTransactionsOfSelectedAccounts(callback: self.handleGetTransactionsResult)