fix(mobile): booking routes on the phone map follow the day they run on

A booking switched on with "On map" stayed drawn on every day of the
phone's plan map, so a flight from the first day crossed the map of the
third, although a day chip frames one day and drops the other days' pins.
The plan map now draws such a booking only on the days it runs on, the
arrival day of an overnight one included, and the all-days view still
shows every booking that is switched on. The switch itself stays
trip-wide, and the desktop, collections and the road trip stage draw
exactly as before.

"On map" in a booking's sheet now reads as on only where the plan map
draws the route. From any other day a tap takes the map to the booking's
day, switching the route on when it is off, instead of hiding a route
that is not drawn there anyway.

The phone settings also gain the "Always show booking routes" switch the
desktop already had. As on the desktop it sets the default for trips not
yet touched on this device, so a trip where a route was switched on or
off by hand keeps that choice.
This commit is contained in:
Maurice
2026-09-22 21:09:51 +02:00
parent 1a8d5a3dd9
commit 93dddaa4af
13 changed files with 424 additions and 15 deletions
+16 -5
View File
@@ -22,10 +22,17 @@ export interface RouteVisibilityOptions {
selectedDayId?: number | null
/** The trip's days, needed to order them — day ids are not monotonic once days have been reordered. */
days?: Day[]
/**
* Hold the per-item toggle to the selected day as well. Off unless asked for: the desktop
* keeps a booking it was told to draw on every day, since switching it on is a deliberate
* act (#2019). The phone's plan map shows one day at a time, and a flight from another
* day drawn across it reads as part of that day.
*/
scopeConnectionsToDay?: boolean
}
/**
* Does this transit journey actually run on the selected day? `showTransitRoutes` is one
* Does this journey actually run on the selected day? `showTransitRoutes` is one
* day's toggle but the reservation list is trip-wide, so without this every automated
* transport in the trip drew its geometry as soon as any day's route was switched on (#2019).
*
@@ -34,7 +41,11 @@ export interface RouteVisibilityOptions {
* A journey bound to no day keeps drawing; hiding something that legitimately belongs
* to today is the worse failure.
*/
function transitRunsOnDay(r: Reservation, selectedDayId: number | null | undefined, days: Day[]): boolean {
export function runsOnDay(
r: Pick<Reservation, 'day_id' | 'end_day_id'>,
selectedDayId: number | null | undefined,
days: Day[],
): boolean {
if (selectedDayId == null) return true
const startDayId = r.day_id ?? r.end_day_id
if (startDayId == null) return true
@@ -45,11 +56,11 @@ function transitRunsOnDay(r: Reservation, selectedDayId: number | null | undefin
/** Which reservations should draw a route on the map, combining the two independent toggles above. */
export function visibleRouteReservations(reservations: Reservation[], options: RouteVisibilityOptions): Reservation[] {
const { visibleConnectionIds, showTransitRoutes, selectedDayId, days } = options
const { visibleConnectionIds, showTransitRoutes, selectedDayId, days, scopeConnectionsToDay } = options
const set = new Set(visibleConnectionIds || [])
return reservations.filter(r =>
(r.type === 'transit' && showTransitRoutes && transitRunsOnDay(r, selectedDayId, days || [])) ||
set.has(r.id)
(r.type === 'transit' && showTransitRoutes && runsOnDay(r, selectedDayId, days || [])) ||
(set.has(r.id) && (!scopeConnectionsToDay || runsOnDay(r, selectedDayId, days || [])))
)
}