From acb16ebff76bd7eb66624f7e9ca3253c478e13c9 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Thu, 18 Dec 2025 12:41:58 +0100 Subject: Show arrivals from previous leg too (to see how much margin you've got to transfer) --- src/frontend/app/routes/planner.tsx | 98 +++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 43 deletions(-) (limited to 'src/frontend') diff --git a/src/frontend/app/routes/planner.tsx b/src/frontend/app/routes/planner.tsx index 55d1553..b1a9813 100644 --- a/src/frontend/app/routes/planner.tsx +++ b/src/frontend/app/routes/planner.tsx @@ -592,15 +592,10 @@ const ItineraryDetail = ({ ) : ( -
- -
+ )} {idx < itinerary.legs.length - 1 && (
@@ -636,44 +631,61 @@ const ItineraryDetail = ({ {t("estimates.minutes")} {leg.mode !== "WALK" && - leg.from?.name && - nextArrivals[leg.from.name] && ( + leg.from?.stopId && + nextArrivals[leg.from.name || leg.from.stopId] && (
{t("planner.next_arrivals", "Next arrivals")}:
- {nextArrivals[leg.from.name] - .filter( - (circ) => - circ.line === - (leg.routeShortName || leg.routeName) - ) - .slice(0, 2) - .map((circ, idx) => { - const minutes = - circ.realTime?.minutes ?? circ.schedule?.minutes; - if (minutes === undefined) return null; - return ( -
- - {circ.line} - - - → - - - {circ.route} - - - {minutes} {t("estimates.minutes")} - {circ.realTime && " 🟢"} - -
- ); - })} + {(() => { + const currentLine = + leg.routeShortName || leg.routeName; + const previousLeg = + idx > 0 ? itinerary.legs[idx - 1] : null; + const previousLine = + previousLeg?.mode !== "WALK" + ? previousLeg?.routeShortName || + previousLeg?.routeName + : null; + + const linesToShow = [currentLine]; + if ( + previousLine && + previousLeg?.to?.stopId === leg.from?.stopId + ) { + linesToShow.push(previousLine); + } + + return nextArrivals[leg.from.name || leg.from.stopId] + .filter((circ) => linesToShow.includes(circ.line)) + .slice(0, 3) + .map((circ, idx) => { + const minutes = + circ.realTime?.minutes ?? + circ.schedule?.minutes; + if (minutes === undefined) return null; + return ( +
+ + {circ.line} + + + → + + + {circ.route} + + + {minutes} {t("estimates.minutes")} + {circ.realTime && " 🟢"} + +
+ ); + }); + })()}
)}
-- cgit v1.3