Skip to content

Commit a46d80c

Browse files
authored
Merge pull request #5782 from HSLdevcom/remove-taxi-option-for-navigator
AB#551 - Disable navigator for itineraries with taxi legs
2 parents b329648 + 3b5ecd7 commit a46d80c

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

app/component/itinerary/ItineraryPage.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import NaviContainer from './navigator/NaviContainer';
9191
import NaviGeolocationInfoModal from './navigator/navigatorgeolocation/NaviGeolocationInfoModal';
9292
import NavigatorIntroModal from './navigator/navigatorintro/NavigatorIntroModal';
9393
import { planConnection } from './queries/PlanConnection';
94+
import { hasTaxiLegs } from '../../util/legUtils';
9495

9596
const MAX_QUERY_COUNT = 4; // number of attempts to collect enough itineraries
9697

@@ -1459,7 +1460,10 @@ export default function ItineraryPage(props, context) {
14591460
Date.now() + 24 * 3600 * 1000;
14601461

14611462
const navigateHook =
1462-
!desktop && config.navigation && presentSearch
1463+
!desktop &&
1464+
config.navigation &&
1465+
presentSearch &&
1466+
!hasTaxiLegs(combinedEdges[selectedIndex]?.node)
14631467
? () =>
14641468
startNavigationWithAnalytics(combinedEdges[selectedIndex]?.node)
14651469
: undefined;

app/util/legUtils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export const LegMode = {
108108
Car: 'CAR',
109109
Rail: 'RAIL',
110110
Wait: 'WAIT',
111+
Taxi: 'TAXI',
111112
};
112113

113114
/**
@@ -134,6 +135,8 @@ export function getLegMode(legOrMode) {
134135
return LegMode.Car;
135136
case LegMode.Rail:
136137
return LegMode.Rail;
138+
case LegMode.Taxi:
139+
return LegMode.Taxi;
137140
default:
138141
return undefined;
139142
}
@@ -460,7 +463,14 @@ function isBikingLeg(leg) {
460463
return [LegMode.Bicycle, LegMode.CityBike].includes(getLegMode(leg));
461464
}
462465
function isDrivingLeg(leg) {
463-
return [LegMode.Car].includes(getLegMode(leg));
466+
return LegMode.Car === getLegMode(leg);
467+
}
468+
function isTaxiLeg(leg) {
469+
return LegMode.Taxi === getLegMode(leg);
470+
}
471+
472+
export function hasTaxiLegs(itinerary) {
473+
return itinerary.legs.some(isTaxiLeg);
464474
}
465475

466476
/**

0 commit comments

Comments
 (0)