From fb056c7da5d655f6668e8f7c5f8c5d834eaf3de8 Mon Sep 17 00:00:00 2001 From: samiuelson Date: Fri, 15 Nov 2024 14:04:30 +0100 Subject: [PATCH] Simplify `isTTPPaymentInProgress` implementation --- .../cardreader/payment/CardReaderPaymentViewModel.kt | 1 - .../payment/controller/CardReaderPaymentController.kt | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt index 2e38f2bd6e8..2cf203da098 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/CardReaderPaymentViewModel.kt @@ -83,7 +83,6 @@ class CardReaderPaymentViewModel @Inject constructor( paymentOrRefund = arguments.paymentOrRefund, cardReaderType = arguments.cardReaderType, isTTPPaymentInProgress = isTTPPaymentInProgress, - onTTPPaymentStateChanged = { isTTPPaymentInProgress = it } ) val viewStateData: LiveData = paymentController.viewStateData diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt index f22e2cd7e7d..f3643127707 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/payment/controller/CardReaderPaymentController.kt @@ -131,8 +131,7 @@ class CardReaderPaymentController( private val paymentReceiptShare: PaymentReceiptShare, private val paymentOrRefund: CardReaderFlowParam.PaymentOrRefund, private val cardReaderType: CardReaderType, - private val isTTPPaymentInProgress: Boolean, - private val onTTPPaymentStateChanged: (Boolean) -> Unit, + private var isTTPPaymentInProgress: Boolean, ) { private val viewState = MutableLiveData(LoadingDataState(::onCancelPaymentFlow)) val viewStateData: LiveData = viewState @@ -231,7 +230,7 @@ class CardReaderPaymentController( return@launch } launch { - onTTPPaymentStateChanged(cardReaderType == CardReaderType.BUILT_IN) + isTTPPaymentInProgress = (cardReaderType == CardReaderType.BUILT_IN) collectPaymentFlow(cardReaderManager, order) } launch {