fooddelivery: show collected pickups as picked up, not driving
- Commit
ea8a6444363496448c0e3dcd3e4b8150accc391b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 19:59 UTC (29 days ago)
- Parents
1668e62
Symptom: a pickup order the customer had already collected kept displaying 'Driving to you' in the orders list and live update, even though isDone already treated it as finished. The tracking progress bar also sat at 65% for it. Root cause: Order.stage mapped pickedupAt unconditionally to DRIVING and never returned OrderStage.PICKED_UP at all, so the pickup milestone list in OrderLiveUpdate (which ends at PICKED_UP) indexed to -1/coerced to 0 and OrdersScreenSection's 'Picked up' colour case never matched the actual label 'Picked Up' either. Fix: return PICKED_UP for a non-delivery order with pickedupAt set (delivery orders still become DRIVING on pickup), match the real label in the status chip, and fill the tracking progress bar for a collected pickup. Verification: updated FoodModelsTotalsTest and StoresAndMiscTest stage-ladder cases to cover both pickup and delivery pickup timestamps; full module test run follows in the final verification.
Diff
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/data/Models.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/data/Models.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/data/Models.ktindex 933fea408f..4d7b2372d8 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/data/Models.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/data/Models.kt@@ -349,6 +349,11 @@ data class Order( val stage: OrderStage get() { if (deliveredAt != null) return OrderStage.DELIVERED+ // A collected pickup is finished, not "driving to you": pickedupAt is the+ // pickup order's terminal timestamp (see isDone), and it is also the final+ // PICKUP milestone the live update expects. Only a delivery order is on+ // the road once it has been picked up from the merchant.+ if (!isDelivery && pickedupAt != null) return OrderStage.PICKED_UP val distance = driverDistanceMiles if (distance != null) { return if (distance <= 0.1) OrderStage.ARRIVING else OrderStage.DRIVING
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.ktindex 84f5e6d454..738498e3c2 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrderTrackingScreen.kt@@ -294,7 +294,7 @@ private fun StageHeader(order: Order) { OrderStage.PREPARING_SOON -> 0.1f OrderStage.PREPARING -> 0.3f OrderStage.READY -> 0.5f- OrderStage.PICKED_UP -> 0.65f+ OrderStage.PICKED_UP -> if (order.isDelivery) 0.65f else 1f OrderStage.DRIVING -> 0.8f OrderStage.ARRIVING -> 0.95f OrderStage.DELIVERED -> 1f
fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreenSection.kt
diff --git a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreenSection.kt b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreenSection.ktindex 65cf9c254d..6e5bb2e5ad 100644--- a/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreenSection.kt+++ b/fooddelivery/src/main/java/com/vayunmathur/fooddelivery/ui/OrdersScreenSection.kt@@ -12,7 +12,7 @@ import com.vayunmathur.library.ui.Text @Composable fun OrdersScreenSection(status: String) { val color = when (status) {- "Delivered", "Picked up" -> MaterialTheme.colorScheme.primary+ "Delivered", "Picked Up" -> MaterialTheme.colorScheme.primary "In progress" -> MaterialTheme.colorScheme.tertiary else -> MaterialTheme.colorScheme.outline }
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.ktindex 1b944661c7..1799079b0f 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/StoresAndMiscTest.kt@@ -86,7 +86,8 @@ class StoresAndMiscTest { @Test fun orderStageDerivation() { assertEquals(OrderStage.DELIVERED, order("""{"deliveredAt":"2024-01-01T00:00:00Z"}""").stage)- assertEquals(OrderStage.DRIVING, order("""{"pickedupAt":"2024-01-01T00:20:00Z"}""").stage)+ assertEquals(OrderStage.PICKED_UP, order("""{"pickedupAt":"2024-01-01T00:20:00Z"}""").stage)+ assertEquals(OrderStage.DRIVING, order("""{"channel":"ORDER_CHANNEL_STOREFRONT_DELIVERY","pickedupAt":"2024-01-01T00:20:00Z"}""").stage) assertEquals(OrderStage.ARRIVING, order("""{"driverReachedCustomerAt":"2024-01-01T00:20:00Z"}""").stage) assertEquals(OrderStage.READY, order("""{"driverReachedMerchantAt":"2024-01-01T00:10:00Z"}""").stage) assertEquals(OrderStage.READY, order("""{"pickupReadyAt":"2024-01-01T00:00:00Z"}""").stage) // ready time in the past
fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodModelsTotalsTest.kt
diff --git a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodModelsTotalsTest.kt b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodModelsTotalsTest.ktindex b05fc9eb27..c31bc071b0 100644--- a/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodModelsTotalsTest.kt+++ b/fooddelivery/src/test/java/com/vayunmathur/fooddelivery/ui/FoodModelsTotalsTest.kt@@ -73,7 +73,10 @@ class FoodModelsTotalsTest { fun orderStageLadderAndEta() { assertEquals(OrderStage.PREPARING, Order().stage) assertEquals(OrderStage.READY, Order(driverReachedMerchantAt = "2024-01-01T00:00:00Z").stage)- assertEquals(OrderStage.DRIVING, Order(pickedupAt = "2024-01-01T00:00:00Z").stage)+ assertEquals(OrderStage.DRIVING, Order(channel = "ORDER_CHANNEL_STOREFRONT_DELIVERY", pickedupAt = "2024-01-01T00:00:00Z").stage)+ // A collected pickup is terminal, matching isDone and the live-update milestones.+ assertEquals(OrderStage.PICKED_UP, Order(pickedupAt = "2024-01-01T00:00:00Z").stage)+ assertEquals("Picked Up", Order(pickedupAt = "2024-01-01T00:00:00Z").displayStatus) assertEquals(OrderStage.ARRIVING, Order(driverReachedCustomerAt = "2024-01-01T00:00:00Z").stage) val future = java.time.Instant.now().plusSeconds(3600).toString() val past = java.time.Instant.now().minusSeconds(3600).toString()