From 0e9097f8cc0b99cc11876093663bdd517dc3e8c4 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 16 May 2020 19:26:49 +0200 Subject: [PATCH] Implemented to not close dialogs when adding a new account to speed things up a bit --- .../main/kotlin/net/dankito/fints/FinTsClient.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt index b49b3335..49331456 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -56,6 +56,8 @@ open class FinTsClient @JvmOverloads constructor( } + open var areWeThatGentleToCloseDialogs: Boolean = true + protected val messageLogField = CopyOnWriteArrayList() open val messageLog: List @@ -99,7 +101,8 @@ open class FinTsClient @JvmOverloads constructor( protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) { - if (dialogContext.didBankCloseDialog) { // bank already closed dialog -> there's no need to send dialog end message + // bank already closed dialog -> there's no need to send dialog end message + if (areWeThatGentleToCloseDialogs == false || dialogContext.didBankCloseDialog) { return } @@ -170,6 +173,9 @@ open class FinTsClient @JvmOverloads constructor( open fun addAccount(bank: BankData, customer: CustomerData): AddAccountResponse { + val originalAreWeThatGentleToCloseDialogs = areWeThatGentleToCloseDialogs + areWeThatGentleToCloseDialogs = false + /* First dialog: Get user's basic data like her TAN procedures */ val newUserInfoResponse = getBankAndCustomerInfoForNewUser(bank, customer) @@ -220,6 +226,8 @@ open class FinTsClient @JvmOverloads constructor( customer.resetSelectedTanProcedure() } + areWeThatGentleToCloseDialogs = originalAreWeThatGentleToCloseDialogs + val supportsRetrievingTransactionsOfLast90DaysWithoutTan = transactionsOfLast90DaysResponses.firstOrNull { it.isSuccessful } != null val unbookedTransactions = transactionsOfLast90DaysResponses.flatMap { it.unbookedTransactions } val bookedTransactions = transactionsOfLast90DaysResponses.flatMap { it.bookedTransactions } @@ -486,7 +494,8 @@ open class FinTsClient @JvmOverloads constructor( protected open fun closeDialog(dialogContext: DialogContext) { - if (dialogContext.didBankCloseDialog) { // bank already closed dialog -> there's no need to send dialog end message + // bank already closed dialog -> there's no need to send dialog end message + if (areWeThatGentleToCloseDialogs == false || dialogContext.didBankCloseDialog) { return }