diff --git a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap index 48064f0f4..f73adeab5 100644 --- a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap +++ b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap @@ -11862,6 +11862,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
viewers > nearby view renders proper scooter dates 1`] = ` }, } } + useArrivalTime={false} >
{ const intl = useIntl() @@ -72,7 +75,7 @@ const StopTimeCell = ({ // Determine whether to show departure as countdown (e.g. "5 min") or as HH:mm // time, using realtime updates if available. const secondsUntilDeparture = Math.round( - getSecondsUntilDeparture(stopTime, false) + getSecondsUntilDeparture(stopTime, false, useArrivalTime) ) // Determine if vehicle arrives after midnight in order to advance the day of // the week when showing arrival time/day. @@ -151,7 +154,8 @@ const StopTimeCell = ({ const mapStateToProps = (state: AppReduxState) => { return { onlyShowCountdownForRealtime: - state.otp.config?.itinerary?.onlyShowCountdownForRealtime || false + state.otp.config?.itinerary?.onlyShowCountdownForRealtime || false, + useArrivalTime: state.otp.config?.nearbyView?.useArrivalTime || false } } diff --git a/lib/util/config-types.ts b/lib/util/config-types.ts index 18e27ca37..a11c51d50 100644 --- a/lib/util/config-types.ts +++ b/lib/util/config-types.ts @@ -73,6 +73,7 @@ export type NearbyViewConfig = { hideEmptyStops?: boolean radius?: number showShadowDotOnMapDrag?: boolean + useArrivalTime?: boolean useRouteViewSort?: boolean } diff --git a/lib/util/viewer.js b/lib/util/viewer.js index 9aabdacc2..faa994560 100644 --- a/lib/util/viewer.js +++ b/lib/util/viewer.js @@ -13,12 +13,23 @@ import { isBlank } from './ui' * Computes the seconds until departure for a given stop time, * based either on the scheduled or the realtime departure time. */ -export function getSecondsUntilDeparture(stopTime, useSchedule) { - const departureTime = useSchedule - ? stopTime.scheduledDeparture - : stopTime.realtimeDeparture +export function getSecondsUntilDeparture( + stopTime, + useSchedule, + useArrivalTime +) { + let time + if (useSchedule) { + time = useArrivalTime + ? stopTime.scheduledArrival + : stopTime.scheduledDeparture + } else { + time = useArrivalTime + ? stopTime.realtimeArrival + : stopTime.realtimeDeparture + } - return departureTime + stopTime.serviceDay - Date.now() / 1000 + return time + stopTime.serviceDay - Date.now() / 1000 } export function getRouteIdForPattern(pattern) {