@@ -26,7 +26,6 @@ import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_FLOW_E
26
26
import com.woocommerce.android.analytics.AnalyticsTrackerWrapper
27
27
import com.woocommerce.android.annotations.OpenClassOnDebug
28
28
import com.woocommerce.android.extensions.isNotEqualTo
29
- import com.woocommerce.android.extensions.semverCompareTo
30
29
import com.woocommerce.android.extensions.whenNotNullNorEmpty
31
30
import com.woocommerce.android.model.Order
32
31
import com.woocommerce.android.model.Order.OrderStatus
@@ -98,12 +97,8 @@ final class OrderDetailViewModel @Inject constructor(
98
97
private val paymentCollectibilityChecker : CardReaderPaymentCollectibilityChecker ,
99
98
private val cardReaderTracker : CardReaderTracker ,
100
99
private val trackerWrapper : AnalyticsTrackerWrapper ,
100
+ private val shippingLabelOnboardingRepository : ShippingLabelOnboardingRepository ,
101
101
) : ScopedViewModel(savedState), OnProductFetchedListener {
102
- companion object {
103
- // The required version to support shipping label creation
104
- const val SUPPORTED_WCS_VERSION = " 1.25.11"
105
- }
106
-
107
102
private val navArgs: OrderDetailFragmentArgs by savedState.navArgs()
108
103
109
104
final var order: Order
@@ -140,12 +135,6 @@ final class OrderDetailViewModel @Inject constructor(
140
135
private val _shippingLabels = MutableLiveData <List <ShippingLabel >>()
141
136
val shippingLabels: LiveData <List <ShippingLabel >> = _shippingLabels
142
137
143
- private val isShippingPluginReady: Boolean by lazy {
144
- val pluginInfo = orderDetailRepository.getWooServicesPluginInfo()
145
- pluginInfo.isInstalled && pluginInfo.isActive &&
146
- (pluginInfo.version ? : " 0.0.0" ).semverCompareTo(SUPPORTED_WCS_VERSION ) >= 0
147
- }
148
-
149
138
override fun onCleared () {
150
139
super .onCleared()
151
140
productImageMap.unsubscribeFromOnProductFetchedEvents(this )
@@ -575,7 +564,7 @@ final class OrderDetailViewModel @Inject constructor(
575
564
}
576
565
577
566
private fun fetchSLCreationEligibilityAsync () = async {
578
- if (isShippingPluginReady) {
567
+ if (shippingLabelOnboardingRepository. isShippingPluginReady) {
579
568
orderDetailRepository.fetchSLCreationEligibility(order.id)
580
569
}
581
570
}
@@ -646,7 +635,7 @@ final class OrderDetailViewModel @Inject constructor(
646
635
val orderEligibleForInPersonPayments = viewState.orderInfo?.isPaymentCollectableWithCardReader == true &&
647
636
FeatureFlag .CARD_READER .isEnabled()
648
637
649
- val isOrderEligibleForSLCreation = isShippingPluginReady &&
638
+ val isOrderEligibleForSLCreation = shippingLabelOnboardingRepository. isShippingPluginReady &&
650
639
orderDetailRepository.isOrderEligibleForSLCreation(order.id) &&
651
640
! orderEligibleForInPersonPayments
652
641
@@ -670,7 +659,10 @@ final class OrderDetailViewModel @Inject constructor(
670
659
isShipmentTrackingAvailable = shipmentTracking.isVisible,
671
660
isProductListVisible = orderProducts.isVisible,
672
661
areShippingLabelsVisible = shippingLabels.isVisible,
673
- installWcShippingBanner = true
662
+ installWcShippingBannerVisible = shippingLabelOnboardingRepository.shouldShowWcShippingBanner(
663
+ order,
664
+ orderEligibleForInPersonPayments
665
+ )
674
666
)
675
667
}
676
668
@@ -711,7 +703,7 @@ final class OrderDetailViewModel @Inject constructor(
711
703
val areShippingLabelsVisible : Boolean? = null ,
712
704
val isProductListMenuVisible : Boolean? = null ,
713
705
val isSharePaymentLinkVisible : Boolean? = null ,
714
- val installWcShippingBanner : Boolean? = null
706
+ val installWcShippingBannerVisible : Boolean? = null
715
707
) : Parcelable {
716
708
val isMarkOrderCompleteButtonVisible: Boolean?
717
709
get() = if (orderStatus != null ) orderStatus.statusKey == CoreOrderStatus .PROCESSING .value else null
0 commit comments