Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gtfs-search): Display GTFS routes in search results. #933

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Changes from 1 commit
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
13 changes: 8 additions & 5 deletions lib/gtfs/components/gtfs-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ 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 isExcluded = excludedEntityIds && excludedEntityIds.includes(route.route_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extract route.route_id and do a null check?

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