Skip to content

Commit

Permalink
set viewedRouteStops when route viewer is active
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Sep 6, 2024
1 parent c4dfc9e commit cd4af5d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ class DefaultMap extends Component {
setLocation,
setViewedStop,
vehicleRentalQuery,
vehicleRentalStations
vehicleRentalStations,
viewedRouteStops
} = this.props
const { getCustomMapOverlays, getTransitiveRouteLabel, ModeIcon } =
this.context
Expand Down Expand Up @@ -405,6 +406,7 @@ class DefaultMap extends Component {
vectorTilesEndpoint,
setLocation,
setViewedStop,
viewedRouteStops,
config.companies
)
default:
Expand All @@ -427,6 +429,19 @@ class DefaultMap extends Component {

const mapStateToProps = (state) => {
const activeSearch = getActiveSearch(state)
const viewedRoute = state.otp?.ui?.viewedRoute?.routeId
const nearbyViewerActive =
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW
const viewedRouteStops =
viewedRoute && !nearbyViewerActive
? Object.entries(
state.otp?.transitIndex?.routes?.[viewedRoute]?.patterns || {}
).reduce((acc, cur) => {
return Array.from(
new Set([...cur?.[1]?.stops.map((s) => s.id), ...acc])
)
}, [])
: null

return {
bikeRentalStations: state.otp.overlay.bikeRental.stations,
Expand All @@ -438,7 +453,8 @@ const mapStateToProps = (state) => {
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW,
pending: activeSearch ? Boolean(activeSearch.pending) : false,
query: state.otp.currentQuery,
vehicleRentalStations: state.otp.overlay.vehicleRental.stations
vehicleRentalStations: state.otp.overlay.vehicleRental.stations,
viewedRouteStops
}
}

Expand Down

0 comments on commit cd4af5d

Please sign in to comment.