updates on the dispatch page faster improvements fix

This commit is contained in:
2026-07-02 12:59:46 +05:30
parent 96db14331b
commit 17faae1f6e

View File

@@ -2150,14 +2150,17 @@ const Dispatch = ({
}
// "All Active Routes": the header must reflect exactly what the list/map
// shows — the in-progress orders and the riders working them — NOT the whole
// day's totals. We count only active deliveries (and `visibleRiders`, which
// is already gated to active-order riders) so the tiles can't disagree with
// the list/map below.
// day's totals. Source from `activeViewRiders`, the SAME sticky-cached list
// that <ActiveSection> renders as cards (see `visibleRiders={activeViewRiders}`
// below) — not `visibleRiders`, which additionally requires a rider to be
// present in the independently-polled GPS-log feed with status 'active'/
// 'pending'. That extra join rarely resolves, which is why this tile used to
// show 0 riders even while real rider cards were on screen.
if (isAllActiveView) {
const activeOrders = allOrders.filter(isActiveDelivery);
const activeOrders = activeViewRiders.flatMap((r) => r.orders);
return {
orders: activeOrders.length,
riders: visibleRiders.length,
riders: activeViewRiders.length,
km: activeOrders.reduce((s, o) => s + parseFloat(o.actualkms || o.kms || 0), 0),
profit: activeOrders.reduce((s, o) => s + parseFloat(o.profit || 0), 0),
label: 'Active Fleet'
@@ -2170,7 +2173,7 @@ const Dispatch = ({
profit: stats.totalProfit,
label: 'Total Fleet'
};
}, [focusedRider, focusedKitchen, isAllActiveView, allViewOrders, visibleRiders, stats]);
}, [focusedRider, focusedKitchen, isAllActiveView, activeViewRiders, stats]);
// List of deliveryids tied to the focused rider's orders — used to drive the
// batched per-delivery GPS log fetch for Compare mode. Deduped; ignores rows
@@ -3253,9 +3256,13 @@ const Dispatch = ({
const routes = [];
const zoneRiderIds = focusedZone ? new Set(focusedZone.riders.map((zr) => String(zr.rider_id))) : null;
if (hidePlanned) return routes;
// visibleRiders === riders in every view except "All Active Routes", where
// it's pre-filtered to riders whose live GPS is currently active.
visibleRiders.forEach(r => {
// In "All Active Routes" draw for exactly the riders shown as cards
// (activeViewRiders) — not `visibleRiders`, which additionally requires a
// rider to be present in the independently-polled GPS-log feed with status
// 'active'/'pending'. That join rarely resolves, which left the map with
// no polyline for a rider whose active-order marker/card was clearly
// visible and clickable. Every other view keeps using `riders` (unfiltered).
(isAllActiveView ? activeViewRiders : riders).forEach(r => {
const isActive = activeRiders.has(r.id);
if (focusedRider && focusedRider.id !== r.id) return;
if (focusedKitchen && !focusedKitchen.riders.has(r.id)) return;