Fixed that update(All|Selected)AccountsTransactionsAsync() didn't call callback if there are no accounts to update so that UI couldn't update / reset its state
This commit is contained in:
parent
75525d704a
commit
31cc59c88e
|
@ -348,20 +348,30 @@ open class BankingPresenter(
|
||||||
updateAllAccountsTransactionsAsync()
|
updateAllAccountsTransactionsAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun updateAllAccountsTransactionsAsync(callback: ((GetTransactionsResponse) -> Unit)? = null) {
|
open fun updateAllAccountsTransactionsAsync(done: (() -> Unit)? = null) {
|
||||||
val accountsToUpdate = allAccounts.filter { considerAccountInAutomaticUpdates(it) }
|
val accountsToUpdate = allAccounts.filter { considerAccountInAutomaticUpdates(it) }
|
||||||
|
|
||||||
updateAccountsTransactionsAsync(accountsToUpdate, true, callback)
|
if (accountsToUpdate.isNotEmpty()) {
|
||||||
|
updateAccountsTransactionsAsync(accountsToUpdate, true) { done?.invoke() }
|
||||||
|
}
|
||||||
|
else if (allAccounts.isNotEmpty()) {
|
||||||
|
done?.invoke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun updateSelectedAccountsTransactionsAsync(callback: ((GetTransactionsResponse) -> Unit)? = null) {
|
open fun updateSelectedAccountsTransactionsAsync(done: (() -> 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))) {
|
||||||
accountsToUpdate = selectedAccounts
|
accountsToUpdate = selectedAccounts
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAccountsTransactionsAsync(accountsToUpdate, false, callback)
|
if (accountsToUpdate.isNotEmpty()) {
|
||||||
|
updateAccountsTransactionsAsync(accountsToUpdate, false) { done?.invoke() }
|
||||||
|
}
|
||||||
|
else if (allAccounts.isNotEmpty()) {
|
||||||
|
done?.invoke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun considerAccountInAutomaticUpdates(account: TypedBankAccount): Boolean {
|
protected open fun considerAccountInAutomaticUpdates(account: TypedBankAccount): Boolean {
|
||||||
|
|
Loading…
Reference in New Issue