Skip to content

Commit

Permalink
Merge pull request #1308 from opentripplanner/fix-operator-icon-viewr…
Browse files Browse the repository at this point in the history
…outes-bug

Only call stopTimes if we don't already have the data
  • Loading branch information
amy-corson-ibigroup authored Dec 3, 2024
2 parents 74f8656 + 7c04e59 commit f7ed865
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ export const fetchNearby = (position, radius, currentServiceWeek) => {

export const findStopTimesForStop = (params) =>
function (dispatch, getState) {
// If the stop is already in the store, don't fetch it again, unless we are forcing a refetch
if (!params.forceFetch && getState().otp.transitIndex.stops[params.stopId])
return

dispatch(fetchingStopTimesForStop(params))
const { date, stopId } = params
const timeZone = getState().otp.config.homeTimezone
Expand Down
8 changes: 6 additions & 2 deletions lib/components/viewers/stop-schedule-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import TimezoneWarning from './timezone-warning'
interface Props {
calendarMax: string
calendarMin: string
findStopTimesForStop: (arg: { date: string; stopId: string }) => void
findStopTimesForStop: (arg: {
date: string
forceFetch?: boolean
stopId: string
}) => void
hideBackButton?: boolean
homeTimezone: string
intl: IntlShape
Expand Down Expand Up @@ -137,7 +141,7 @@ class StopScheduleViewer extends Component<Props, State> {
_findStopTimesForDate = (date: string) => {
const { findStopTimesForStop, stopId } = this.props
if (stopId) {
findStopTimesForStop({ date, stopId })
findStopTimesForStop({ date, forceFetch: true, stopId })
}
}

Expand Down

0 comments on commit f7ed865

Please sign in to comment.