Skip to content

Commit

Permalink
changed routes api (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghoster981 committed Apr 5, 2023
1 parent f2aef2b commit 14a0898
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion journey/src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ export function findRoute (params) {
id: gtfsId
mode
longName
shortName
color
textColor
patterns {
Expand Down Expand Up @@ -740,7 +741,7 @@ export function findRoute (params) {
})
return {
routeId: params.routeId,
mode: payload.data.route?.mode,
... payload.data.route,
patterns
}
}
Expand Down
4 changes: 2 additions & 2 deletions journey/src/components/routes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Search extends Component {
componentDidUpdate(prevProps) {
// initialize list if was previously empty
if (
prevProps.completeList?.length === 0 &&
this.props.completeList?.length > 0
prevProps.completeList?.length <=1 &&
this.props.completeList?.length >1
) {
const filteredList = this.filter(
this.props.completeList,
Expand Down
7 changes: 4 additions & 3 deletions journey/src/reducers/create-otp-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,17 +870,18 @@ function createOtpReducer (config, initialQuery) {
}
})
case 'FIND_PATTERNS_FOR_ROUTE_RESPONSE':
const { patterns, routeId, mode } = action.payload
const {routeId, ...data} = action.payload
// If routes is undefined, initialize it w/ this route only
if (!state.transitIndex.routes) {
return update(state, {
transitIndex: { routes: { $set: { [routeId]: { patterns, mode } } } }
transitIndex: { routes: { $set: { [routeId]: data } } }
})
}
// Otherwise, overwrite only this route

return update(state, {
transitIndex: {
routes: { [routeId]: { patterns: { $set: patterns } } }
routes: { [routeId]: {$set: data } }
}
})
case 'FIND_GEOMETRY_FOR_PATTERN_RESPONSE':
Expand Down

0 comments on commit 14a0898

Please sign in to comment.