From b5756c909f3e382e7bc9b0d6586aa3c429733b1e Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 27 Sep 2020 00:51:44 +0200 Subject: [PATCH] Fixed that executeMutatingMethod() got executed on each view update --- .../ui/dialogs/AccountTransactionsDialog.swift | 8 +++++++- .../ui/views/tan/FlickerCodeTanView.swift | 13 ++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift index dcac9ef3..d7643f07 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift @@ -46,6 +46,8 @@ struct AccountTransactionsDialog: View { @State private var errorMessage: Message? = nil + + @State private var isInitialized = false @Inject private var presenter: BankingPresenterSwift @@ -142,7 +144,11 @@ struct AccountTransactionsDialog: View { .systemGroupedBackground() } .executeMutatingMethod { - self.setInitialValues() + if isInitialized == false { + isInitialized = true + + self.setInitialValues() + } } .alert(message: $errorMessage) .showNavigationBarTitle(LocalizedStringKey(title)) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/tan/FlickerCodeTanView.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/tan/FlickerCodeTanView.swift index d79dc3bc..f1d24f14 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/tan/FlickerCodeTanView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/tan/FlickerCodeTanView.swift @@ -72,6 +72,9 @@ struct FlickerCodeTanView: View { } + @State private var isInitialized = false + + init(_ tanChallenge: BankingUiSwift.FlickerCodeTanChallenge) { self.tanChallenge = tanChallenge @@ -149,9 +152,13 @@ struct FlickerCodeTanView: View { } // what a hack to be able to call animator.animate() (otherwise compiler would throw 'use of immutable self in closure' error) .executeMutatingMethod { - self.calculateStripeWidth() - - self.animator.animate(self.tanChallenge.flickerCode.parsedDataSet, self.showStep) + if isInitialized == false { + isInitialized = true + + self.calculateStripeWidth() + + self.animator.animate(self.tanChallenge.flickerCode.parsedDataSet, self.showStep) + } } }