fix(native): show the travel day's Live Activity from three hours before its first stop

The Live Activity started with the first sync of a travel day and stayed on
the lock screen all day, so a day whose first stop is an evening flight held
it from the early morning on. It now appears three hours before the day's
first timed stop and stays until the day is done; liveDayDue() decides.
This commit is contained in:
Maurice
2026-11-12 14:00:47 +01:00
parent a1d3ffc2ce
commit b8ec428ad1
3 changed files with 57 additions and 3 deletions
+17
View File
@@ -357,6 +357,23 @@ export function tripDayState(day: TripDay, nowMinutes: number, allDone: string):
};
}
/** How long before the day's first timed stop its Live Activity appears. */
export const LIVE_LEAD_MINUTES = 3 * 60;
/**
* Whether the travel day's Live Activity belongs on the lock screen now: from
* three hours before the first stop with a time, then until the day is done. A
* day whose first stop is an evening flight does not hold the lock screen from
* the morning on.
*/
export function liveDayDue(day: TripDay, nowMinutes: number): boolean {
const first = day.stops.reduce<number | null>(
(min, s) => (s.minutes != null && (min === null || s.minutes < min) ? s.minutes : min),
null
);
return first !== null && nowMinutes >= first - LIVE_LEAD_MINUTES;
}
/** A trip a widget can be set to in Edit Widget, and its snapshot. */
export interface TripWidgetSnapshot {
id: number;