Fixed that if persisting newly added account fails callback never gets called and AddAccountDialog therefore is stuck forever

This commit is contained in:
dankito 2020-10-08 00:41:01 +02:00
parent 2cab245600
commit 12d6c5a430
1 changed files with 22 additions and 15 deletions

View File

@ -174,28 +174,35 @@ open class BankingPresenter(
newClient.addAccountAsync { response ->
if (response.successful) {
val bank = response.bank
bank.displayIndex = allBanks.size
addClientForBank(bank, newClient)
selectedBank(bank)
callBanksChangedListeners()
persistBankOffUiThread(bank)
response.retrievedData.forEach { retrievedData ->
retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false)
try {
handleSuccessfullyAddedBank(response.bank, newClient, response, startDate)
} catch (e: Exception) {
log.error(e) { "Could not save successfully added bank" }
}
findIconForBankAsync(bank)
}
callback(response)
}
}
protected open fun handleSuccessfullyAddedBank(bank: TypedBankData, newClient: IBankingClient, response: AddAccountResponse, startDate: Date) {
bank.displayIndex = allBanks.size
addClientForBank(bank, newClient)
selectedBank(bank)
callBanksChangedListeners()
findIconForBankAsync(bank)
persistBankOffUiThread(bank)
response.retrievedData.forEach { retrievedData ->
retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false)
}
}
protected open fun findIconForBankAsync(bank: TypedBankData) {
bankIconFinder.findIconForBankAsync(bank.bankName) { bankIconUrl ->
bankIconUrl?.let {