Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/gtfs/components/gtfs-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,17 @@ class GtfsSearch extends Component<Props, State> {
stops && stopOptions.push(...stops.map(s => _entityToOption(s, feed)))
routes && routeOptions.push(
...routes
// Remove specified entity ids (route ids in this case) to exclude, except the current value.
.filter(route =>
!excludedEntityIds.includes(route.route_id) ||
// (Extended type checks are for flow validation.)
(route.route_id === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption))
// Keep routes whose ids are not excluded and that are not the one selected in the dropdown.
.filter(route => {
const { route_id: routeId } = route
if (routeId === null || routeId === undefined) return false

const isExcluded = excludedEntityIds && excludedEntityIds.includes(routeId)
const isSameAsCurrent =
// (Extended type checks are for flow validation.)
routeId === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption)
return !isExcluded && !isSameAsCurrent
}
)
.map(r => _entityToOption(r, feed))
)
Expand Down