Fixed that if persisting newly added account fails callback never gets called and AddAccountDialog therefore is stuck forever
This commit is contained in:
parent
2cab245600
commit
12d6c5a430
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue