From 21f204ad4ea00a023b7a332c430e50a648b8e65b Mon Sep 17 00:00:00 2001 From: samiuelson Date: Fri, 17 Jan 2025 11:51:02 +0100 Subject: [PATCH] Switch between store management and POS variants of `PaymentsFlowTracker` in `CardReaderOnboardingViewModel` --- .../onboarding/CardReaderOnboardingViewModel.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/onboarding/CardReaderOnboardingViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/onboarding/CardReaderOnboardingViewModel.kt index 25d49b97ba5..dad30b23ccf 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/onboarding/CardReaderOnboardingViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/cardreader/onboarding/CardReaderOnboardingViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.SavedStateHandle import com.woocommerce.android.AppPrefsWrapper import com.woocommerce.android.cardreader.CardReaderManager +import com.woocommerce.android.di.PointOfSaleMode +import com.woocommerce.android.di.StoreManagementMode import com.woocommerce.android.extensions.formatToMMMMdd import com.woocommerce.android.model.UiString import com.woocommerce.android.tools.SelectedSite @@ -70,8 +72,9 @@ private const val UNIX_TO_JAVA_TIMESTAMP_OFFSET = 1000L @HiltViewModel class CardReaderOnboardingViewModel @Inject constructor( savedState: SavedStateHandle, + @PointOfSaleMode storeManagementPaymentsFlowTracker: PaymentsFlowTracker, + @StoreManagementMode pointOfSalePaymentsFlowTracker: PaymentsFlowTracker, private val cardReaderChecker: CardReaderOnboardingChecker, - private val paymentsFlowTracker: PaymentsFlowTracker, private val learnMoreUrlProvider: LearnMoreUrlProvider, private val selectedSite: SelectedSite, private val appPrefsWrapper: AppPrefsWrapper, @@ -80,6 +83,7 @@ class CardReaderOnboardingViewModel @Inject constructor( private val errorClickHandler: CardReaderOnboardingErrorCtaClickHandler, ) : ScopedViewModel(savedState) { private val arguments: CardReaderOnboardingFragmentArgs by savedState.navArgs() + private val paymentsFlowTracker: PaymentsFlowTracker override val _event = SingleLiveEvent() override val event: LiveData = _event @@ -102,6 +106,10 @@ class CardReaderOnboardingViewModel @Inject constructor( is Check -> refreshState(onboardingParam.pluginType) is Failed -> showOnboardingState(onboardingParam.onboardingState) } + paymentsFlowTracker = when { + isPos -> pointOfSalePaymentsFlowTracker + else -> storeManagementPaymentsFlowTracker + } } private fun refreshState(pluginType: PluginType? = null) {