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 -> newClient.addAccountAsync { response ->
if (response.successful) { if (response.successful) {
val bank = response.bank try {
bank.displayIndex = allBanks.size handleSuccessfullyAddedBank(response.bank, newClient, response, startDate)
} catch (e: Exception) {
addClientForBank(bank, newClient) log.error(e) { "Could not save successfully added bank" }
selectedBank(bank)
callBanksChangedListeners()
persistBankOffUiThread(bank)
response.retrievedData.forEach { retrievedData ->
retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false)
} }
findIconForBankAsync(bank)
} }
callback(response) 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) { protected open fun findIconForBankAsync(bank: TypedBankData) {
bankIconFinder.findIconForBankAsync(bank.bankName) { bankIconUrl -> bankIconFinder.findIconForBankAsync(bank.bankName) { bankIconUrl ->
bankIconUrl?.let { bankIconUrl?.let {