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

set viewedRouteStops when route viewer is active #1270

Merged
merged 11 commits into from
Sep 25, 2024
28 changes: 25 additions & 3 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,7 +406,7 @@ class DefaultMap extends Component {
vectorTilesEndpoint,
setLocation,
setViewedStop,
null,
viewedRouteStops,
config.companies
)
default:
Expand All @@ -428,6 +429,26 @@ 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 viewedRoutePatterns = Object.entries(
state.otp?.transitIndex?.routes?.[viewedRoute]?.patterns || {}
)
const viewedRouteStops =
viewedRoute && !nearbyViewerActive
? // Ensure we don't have duplicates
Array.from(
new Set(
// Generate a list of every stop id the pattern stops at
viewedRoutePatterns.reduce((acc, cur) => {
// Convert pattern object to list of the pattern's stops
return [...cur?.[1]?.stops.map((s) => s.id), ...acc]
}, [])
)
)
: null

return {
bikeRentalStations: state.otp.overlay.bikeRental.stations,
Expand All @@ -439,7 +460,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
2 changes: 1 addition & 1 deletion lib/components/map/point-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function MapPopup({
// Override inline style supplied by react-map-gl to accommodate long "plan a trip" translations.
style={{ maxWidth: '260px', width: '260px' }}
>
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="stop-popup">
<FocusTrapWrapper closePopup={clearMapPopupLocation} id="point-popup">
<PopupTitleWrapper>
<PopupTitle>
{typeof popupName === 'string' && popupName.split(',').length > 3
Expand Down
Loading