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,7 +174,18 @@ open class BankingPresenter(
newClient.addAccountAsync { response -> newClient.addAccountAsync { response ->
if (response.successful) { if (response.successful) {
val bank = response.bank try {
handleSuccessfullyAddedBank(response.bank, newClient, response, startDate)
} catch (e: Exception) {
log.error(e) { "Could not save successfully added bank" }
}
}
callback(response)
}
}
protected open fun handleSuccessfullyAddedBank(bank: TypedBankData, newClient: IBankingClient, response: AddAccountResponse, startDate: Date) {
bank.displayIndex = allBanks.size bank.displayIndex = allBanks.size
addClientForBank(bank, newClient) addClientForBank(bank, newClient)
@ -183,17 +194,13 @@ open class BankingPresenter(
callBanksChangedListeners() callBanksChangedListeners()
findIconForBankAsync(bank)
persistBankOffUiThread(bank) persistBankOffUiThread(bank)
response.retrievedData.forEach { retrievedData -> response.retrievedData.forEach { retrievedData ->
retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false) retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false)
} }
findIconForBankAsync(bank)
}
callback(response)
}
} }
protected open fun findIconForBankAsync(bank: TypedBankData) { protected open fun findIconForBankAsync(bank: TypedBankData) {