Skip to content

Commit 7a75386

Browse files
replace with acceptableValidModeCombos
1 parent 308a3cc commit 7a75386

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Diff for: example-config.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ routingTypes:
348348

349349
# Itinerary options
350350
itinerary:
351+
# Provides an array of valid mode combinations that returned itineraries will be filtered against
352+
# If left blank, all itineraries deemed valid by OTP will be returned
353+
acceptableValidModeCombos: [
354+
['WALK'],
355+
['WALK', 'PERSONAL'],
356+
['WALK', 'TRANSIT', 'SHARED'],
357+
['WALK', 'SHARED'],
358+
['WALK', 'TRANSIT'],
359+
['WALK', 'TRANSIT', 'PERSONAL'],
360+
['WALK', 'TRANSIT', 'CAR'],
361+
['CAR']
362+
]
351363
# Show fares for each transit leg (false if omitted).
352364
# (Requires using LineItinerary.)
353365
showRouteFares: false
@@ -363,9 +375,6 @@ itinerary:
363375
# Filters out trips returned by OTP by default, unless specifically requested.
364376
# e.g. filters out walk-only itineraries if user has not explicitly asked for them.
365377
strictItineraryFiltering: false
366-
# Whether to filter out itineraries that do not match our list of valid mode combinations
367-
# (e.g. "WALK" + "DRIVE")
368-
strictValidCombos: false
369378
# Whether to render route names and colors in the blocks inside
370379
# the batch ui rows
371380
renderRouteNamesInBlocks: true

Diff for: lib/actions/apiV2.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ const { randId } = coreUtils.storage
7373

7474
const LIGHT_GRAY = '666666'
7575

76-
const VALID_COMBOS = [
77-
['WALK'],
78-
['WALK', 'PERSONAL'],
79-
['WALK', 'TRANSIT', 'SHARED'],
80-
['WALK', 'SHARED'],
81-
['WALK', 'TRANSIT'],
82-
['WALK', 'TRANSIT', 'PERSONAL'],
83-
['WALK', 'TRANSIT', 'CAR'],
84-
['CAR']
85-
]
86-
8776
function formatRecentPlace(place) {
8877
return convertToPlace({
8978
...place,
@@ -993,7 +982,8 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
993982
{}
994983

995984
const strictModes = !!config?.itinerary?.strictItineraryFiltering
996-
const strictValidCombos = !!config?.itinerary?.strictValidCombos
985+
const acceptableValidModeCombos =
986+
config?.itinerary?.acceptableValidModeCombos
997987

998988
// Filter mode definitions based on active mode keys
999989
const activeModeButtons = config.modes?.modeButtons.filter((mb) =>
@@ -1126,15 +1116,16 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
11261116
activeModeStrings.includes(SIMPLIFICATIONS[leg.mode])
11271117
)
11281118
)
1129-
// If "strictValidCombos" is enabled, filter out itineraries that do not match our list of valid mode combinations
1119+
// If "acceptableValidModeCombos" is provided, filter out itineraries that do not match our list of valid mode combinations
11301120
// (e.g. "WALK" + "DRIVE")
1131-
// TODO: Remove this and VALID_COMBOS once we switch to planConnection API
1132-
if (strictValidCombos) {
1121+
// TODO: Remove this once we switch to planConnection API
1122+
if (acceptableValidModeCombos?.length > 0) {
1123+
console.log(!!acceptableValidModeCombos)
11331124
filteredItineraries = filteredItineraries.filter((itin) => {
11341125
const modeCombo = Array.from(
11351126
new Set(itin.legs.map((leg) => SIMPLIFICATIONS[leg.mode]))
11361127
)
1137-
return !!VALID_COMBOS.find(
1128+
return !!acceptableValidModeCombos.find(
11381129
(vc) =>
11391130
modeCombo.every((m) => vc.includes(m)) &&
11401131
vc.every((m) => modeCombo.includes(m))

0 commit comments

Comments
 (0)