Skip to content

Commit

Permalink
Switch between store management and POS variants of `PaymentsFlowTrac…
Browse files Browse the repository at this point in the history
…ker` in `CardReaderOnboardingViewModel`
  • Loading branch information
samiuelson committed Jan 17, 2025
1 parent 970ea68 commit 21f204a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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<Event>()
override val event: LiveData<Event> = _event
Expand All @@ -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) {
Expand Down

0 comments on commit 21f204a

Please sign in to comment.