Skip to content

Commit b3ee1f4

Browse files
Rename property name to better clarify its role
1 parent 61dcbc1 commit b3ee1f4

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/ShippableItemsMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private fun getShipmentCostUI(
153153
currencyFormatter: (BigDecimal) -> String
154154
): ShipmentCostUI? {
155155
return when {
156-
shipmentUIModel.purchased -> {
156+
shipmentUIModel.isPurchasedOrInProgress -> {
157157
requireNotNull(shipmentUIModel.label)
158158
ShipmentCostUI(
159159
serviceName = shipmentUIModel.label.serviceName,

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class WooShippingLabelCreationViewModel @Inject constructor(
202202
}
203203

204204
private suspend fun trackScreenShownEvent() {
205-
val unfulfilledShipmentsCount = shipments.drop(1).first().count { !it.purchased }
205+
val unfulfilledShipmentsCount = shipments.drop(1).first().count { !it.isPurchasedOrInProgress }
206206
analyticsTracker.track(
207207
AnalyticsEvent.WCS_CREATE_SHIPPING_LABEL_FORM_SHOWN,
208208
mapOf("unfulfilled_shipments_count" to unfulfilledShipmentsCount)
@@ -225,7 +225,7 @@ class WooShippingLabelCreationViewModel @Inject constructor(
225225
) { shipments, selectedShipmentIndex ->
226226
shipments[selectedShipmentIndex]
227227
}.flatMapLatest { shipment ->
228-
if (shipment.purchased) {
228+
if (shipment.isPurchasedOrInProgress) {
229229
flowOf(null)
230230
} else {
231231
observeShippingLabelNotice(
@@ -582,7 +582,7 @@ class WooShippingLabelCreationViewModel @Inject constructor(
582582
uiState.map { it.selectedIndex }.distinctUntilChanged(),
583583
) { order, destination, originAddresses, shipments, selectedIndex ->
584584
val currentShipment = shipments[selectedIndex]
585-
val updatedAddress = if (currentShipment.purchased) {
585+
val updatedAddress = if (currentShipment.isPurchasedOrInProgress) {
586586
val selectedAddress = shippingAddresses.value.getOrNull(selectedShipmentIndex)
587587
val shipFrom = selectedAddress?.shipFrom?.takeIf { it != OriginShippingAddress.EMPTY }
588588
?: currentShipment.label?.originAddress?.let { originAddress ->

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/models/ShipmentUIModel.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ data class ShipmentUIModel(
1111
val isPurchaseAPILoading: Boolean = false,
1212
val label: ShippingLabelModel? = null,
1313
) : Parcelable {
14-
/**
15-
* Whether the shipment has been purchased or not.
16-
* A shipment is considered purchased if the label was already purchased or is in the process of being purchased.
17-
*/
18-
val purchased: Boolean
14+
val isPurchasedOrInProgress: Boolean
1915
get() = label?.status == ShippingLabelStatus.PURCHASE_IN_PROGRESS ||
2016
(label?.status == ShippingLabelStatus.PURCHASED && label.refund == null)
2117
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/split/GetSplitMovements.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class GetSplitMovements @Inject constructor() {
6767
items: Map<Int, ShipmentUIModel>,
6868
isRemoveMovement: Boolean
6969
): List<Int> {
70-
val otherUnfulfilledKeys = items.filterNot { it.key == sourceShipmentKey || it.value.purchased }.keys.toList()
70+
val otherUnfulfilledKeys = items.filterNot { it.key == sourceShipmentKey || it.value.isPurchasedOrInProgress }.keys.toList()
7171
if (isRemoveMovement) return otherUnfulfilledKeys
7272

7373
val otherKeys = items.keys.filter { it != sourceShipmentKey }

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/split/WooShippingSplitShipmentViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class WooShippingSplitShipmentViewModel @Inject constructor(
5858
currencyFormatter = currencyFormatter,
5959
dimensionUnit = storeOptions.dimensionUnit,
6060
weightUnit = storeOptions.weightUnit,
61-
purchased = it.value.purchased
61+
purchased = it.value.isPurchasedOrInProgress
6262
)
6363
}
6464

@@ -174,8 +174,8 @@ class WooShippingSplitShipmentViewModel @Inject constructor(
174174
}
175175

176176
private fun mergeUnfulfilledShipments() {
177-
val fulfilledShipments = currentShipments.value.filter { it.value.purchased }
178-
val unfulfilledShipments = currentShipments.value.filterNot { it.value.purchased }
177+
val fulfilledShipments = currentShipments.value.filter { it.value.isPurchasedOrInProgress }
178+
val unfulfilledShipments = currentShipments.value.filterNot { it.value.isPurchasedOrInProgress }
179179
val firstUnfulfilledShipmentKey = unfulfilledShipments.keys.first()
180180
val firstUnfulfilledShipmentValue = unfulfilledShipments.values.first()
181181
val mergedShipmentUIModel = firstUnfulfilledShipmentValue.copy(

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/GetShipmentsTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class GetShipmentsTests : BaseUnitTest() {
228228
val result = sut.invoke(order)
229229
val shipmentUIModel = result.first()
230230

231-
assertFalse(shipmentUIModel.purchased)
231+
assertFalse(shipmentUIModel.isPurchasedOrInProgress)
232232
}
233233

234234
@Test
@@ -275,7 +275,7 @@ class GetShipmentsTests : BaseUnitTest() {
275275
val result = sut.invoke(order)
276276
val shipmentUIModel = result.first()
277277

278-
assertFalse(shipmentUIModel.purchased)
278+
assertFalse(shipmentUIModel.isPurchasedOrInProgress)
279279
}
280280

281281
@Test
@@ -322,7 +322,7 @@ class GetShipmentsTests : BaseUnitTest() {
322322
val result = sut.invoke(order)
323323
val shipmentUIModel = result.first()
324324

325-
assertTrue(shipmentUIModel.purchased)
325+
assertTrue(shipmentUIModel.isPurchasedOrInProgress)
326326
assertNotNull(shipmentUIModel.label)
327327
}
328328
}

0 commit comments

Comments
 (0)