Skip to content

Commit

Permalink
refactor: address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Sep 23, 2024
1 parent bfca0e4 commit b944509
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/components/map/default-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,22 @@ const mapStateToProps = (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
? Object.entries(
state.otp?.transitIndex?.routes?.[viewedRoute]?.patterns || {}
).reduce((acc, cur) => {
return Array.from(
new Set([...cur?.[1]?.stops.map((s) => s.id), ...acc])
? // 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 {
Expand Down

0 comments on commit b944509

Please sign in to comment.