Fixed that getUsersTanMethod() is async but caller had no chance to wait for response

This commit is contained in:
dankito 2020-10-04 20:39:32 +02:00
parent ee38799cad
commit 63ec9e074a
1 changed files with 15 additions and 11 deletions

View File

@ -182,8 +182,7 @@ open class FinTsClient(
} }
else { else {
bank.tanMethodsAvailableForUser = bank.tanMethodSupportedByBank bank.tanMethodsAvailableForUser = bank.tanMethodSupportedByBank
getUsersTanMethod(bank) getUsersTanMethod(bank) {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
initDialogWithStrongCustomerAuthenticationAfterSuccessfulPreconditionChecks(dialogContext) { initDialogResponse -> initDialogWithStrongCustomerAuthenticationAfterSuccessfulPreconditionChecks(dialogContext) { initDialogResponse ->
@ -194,6 +193,7 @@ open class FinTsClient(
} }
} }
} }
}
protected open fun getAccounts(bank: BankData, callback: (BankResponse) -> Unit) { protected open fun getAccounts(bank: BankData, callback: (BankResponse) -> Unit) {
@ -632,30 +632,34 @@ open class FinTsClient(
callback(BankResponse(false, noTanMethodSelected = true)) callback(BankResponse(false, noTanMethodSelected = true))
} }
else { else {
getUsersTanMethod(bank) getUsersTanMethod(bank) {
callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected)) callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected))
} }
} }
} }
}
else { else {
getUsersTanMethod(bank) getUsersTanMethod(bank) {
callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected)) callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected))
} }
} }
}
else { else {
callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected)) callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected))
} }
} }
protected open fun getUsersTanMethod(bank: BankData) { protected open fun getUsersTanMethod(bank: BankData, done: () -> Unit) {
if (bank.tanMethodsAvailableForUser.size == 1) { // user has only one TAN method -> set it and we're done if (bank.tanMethodsAvailableForUser.size == 1) { // user has only one TAN method -> set it and we're done
bank.selectedTanMethod = bank.tanMethodsAvailableForUser.first() bank.selectedTanMethod = bank.tanMethodsAvailableForUser.first()
done()
} }
else { else {
// we know user's supported tan methods, now ask user which one to select // we know user's supported tan methods, now ask user which one to select
callback.askUserForTanMethod(bank.tanMethodsAvailableForUser, selectSuggestedTanMethod(bank)) { selectedTanMethod -> callback.askUserForTanMethod(bank.tanMethodsAvailableForUser, selectSuggestedTanMethod(bank)) { selectedTanMethod ->
selectedTanMethod?.let { selectedTanMethod?.let {
bank.selectedTanMethod = selectedTanMethod bank.selectedTanMethod = selectedTanMethod
done()
} }
} }
} }