Skip to content

Commit

Permalink
Merge pull request #4861 from HSLdevcom/DT-5826
Browse files Browse the repository at this point in the history
Don't show alternative later legs from too far in the future
  • Loading branch information
vesameskanen authored Sep 19, 2023
2 parents 88994b6 + 9a5eee7 commit 11b195e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/component/TransitLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ class TransitLeg extends React.Component {
};
}

// Some next legs might be for example 24h in the future which seems confusing. Only show alternatives that are less than 12h in the future.
filterNextLegs = leg => {
if (!leg.nextLegs) {
return [];
}
return leg.nextLegs.filter(
nextLeg =>
moment(nextLeg.startTime).diff(moment(leg.startTime), 'hours') < 12,
);
};

stopCode = stopCode => stopCode && <StopCode code={stopCode} />;

isRouteConstantOperation = () =>
Expand All @@ -57,7 +68,7 @@ class TransitLeg extends React.Component {

displayAlternativeLegs = () =>
!!this.context.config.showAlternativeLegs &&
this.props.leg.nextLegs?.length > 0 &&
this.filterNextLegs(this.props.leg).length > 0 &&
!this.isRouteConstantOperation();

toggleShowIntermediateStops = () => {
Expand Down Expand Up @@ -465,7 +476,7 @@ class TransitLeg extends React.Component {
))}
{this.displayAlternativeLegs() && (
<AlternativeLegsInfo
legs={leg.nextLegs}
legs={this.filterNextLegs(leg)}
showAlternativeLegs={this.state.showAlternativeLegs}
toggle={() =>
this.setState(prevState => ({
Expand Down

0 comments on commit 11b195e

Please sign in to comment.