Skip to content

Commit

Permalink
fix: use correct check for realtime availability
Browse files Browse the repository at this point in the history
No realtime state occurs when transit has departed from
its first stop more than 2 minutes ago.
  • Loading branch information
vesameskanen committed Dec 16, 2024
1 parent 61d9efa commit 1481c3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/component/itinerary/PlanConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const planConnection = graphql`
gtfsId
}
scheduledDeparture
serviceDay
}
stoptimes {
stop {
Expand Down
11 changes: 9 additions & 2 deletions app/component/itinerary/navigator/NaviUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ export const getTransitLegState = (leg, intl, messages, time) => {
</div>
);
severity = 'WARNING';
} else if (!isRealTime && legTime(start) - time < DISPLAY_MESSAGE_THRESHOLD) {
} else if (!isRealTime) {
const departure = leg.trip.stoptimesForDate[0];
const departed =
1000 * (departure.serviceDay + departure.scheduledDeparture);
if (time - departed < DISPLAY_MESSAGE_THRESHOLD) {
// vehicle just departed, maybe no realtime yet
return [];
}
severity = 'WARNING';
content = (
<div className="navi-info-content">
Expand All @@ -246,7 +253,7 @@ export const getTransitLegState = (leg, intl, messages, time) => {
/>
</div>
);
} else if (isRealTime) {
} else {
const { parentStation, name } = from.stop;
const stopOrStation = parentStation
? intl.formatMessage({ id: 'from-station' })
Expand Down

0 comments on commit 1481c3f

Please sign in to comment.