Skip to content

Commit 2149740

Browse files
Merge pull request #617 from opentripplanner/june-call-taker-fixes
CallTaker Regression Fixes
2 parents 9cf37f0 + 309bcc4 commit 2149740

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

Diff for: lib/actions/plan.js

+40-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
import {OTP_API_DATE_FORMAT, OTP_API_TIME_FORMAT} from '@opentripplanner/core-utils/lib/time'
2-
import {getTimeZoneOffset} from '@opentripplanner/core-utils/lib/itinerary'
1+
import { getTimeZoneOffset } from '@opentripplanner/core-utils/lib/itinerary'
2+
import {
3+
OTP_API_DATE_FORMAT,
4+
OTP_API_TIME_FORMAT
5+
} from '@opentripplanner/core-utils/lib/time'
36
import moment from 'moment'
47

5-
import {getFirstStopId} from '../util/itinerary'
6-
import {getActiveItinerary} from '../util/state'
8+
import { getActiveItinerary } from '../util/state'
9+
import { getFirstStopId } from '../util/itinerary'
710

8-
import {routingQuery} from './api'
9-
import {setQueryParam} from './form'
11+
import { routingQuery } from './api'
12+
import { setQueryParam } from './form'
1013

1114
const SERVICE_BREAK = '03:00'
1215
const NINETY_SECONDS = 90000
1316

14-
function updateParamsAndPlan (params) {
17+
function updateParamsAndPlan(params) {
1518
return function (dispatch, getState) {
1619
dispatch(setQueryParam(params))
1720
dispatch(routingQuery())
1821
}
1922
}
2023

21-
function offsetTime (itinerary, unixTime) {
24+
function offsetTime(itinerary, unixTime) {
2225
let offset = 0
2326
if (itinerary) offset = getTimeZoneOffset(itinerary)
2427
return moment(unixTime + offset)
@@ -28,30 +31,32 @@ function offsetTime (itinerary, unixTime) {
2831
* Effectively checks whether #planFirst has already been clicked, i.e., the
2932
* query is planning a depart at the service break time.
3033
*/
31-
function isPlanningFirst (query) {
32-
const {departArrive, time} = query
34+
function isPlanningFirst(query) {
35+
const { departArrive, time } = query
3336
return departArrive === 'DEPART' && time === SERVICE_BREAK
3437
}
3538

3639
/**
3740
* Plan the first trip of the day, or if the first trip has already been planned,
3841
* plan the first trip of the previous day.
3942
*/
40-
export function planFirst () {
43+
export function planFirst() {
4144
return function (dispatch, getState) {
4245
const state = getState()
4346
const itinerary = getActiveItinerary(state)
44-
const {currentQuery} = state.otp
47+
const { currentQuery } = state.otp
4548
const date = moment(currentQuery.date)
4649
// If already planning for the "first" trip, subtract a day to mirror the
4750
// behavior of planLast.
4851
if (isPlanningFirst(currentQuery)) date.subtract('days', 1)
4952
const params = {
5053
date: date.format(OTP_API_DATE_FORMAT),
5154
departArrive: 'DEPART',
52-
startTransitStopId: getFirstStopId(itinerary),
5355
time: SERVICE_BREAK
5456
}
57+
if (!state.otp?.config?.api?.v2) {
58+
params.startTransitStopId = getFirstStopId(itinerary)
59+
}
5560
dispatch(updateParamsAndPlan(params))
5661
}
5762
}
@@ -60,16 +65,18 @@ export function planFirst () {
6065
* Plan the previous trip, setting the arrive by time to the current itinerary's
6166
* end time (minus a small amount).
6267
*/
63-
export function planPrevious () {
68+
export function planPrevious() {
6469
return function (dispatch, getState) {
6570
const itinerary = getActiveItinerary(getState())
6671
const newEndTime = offsetTime(itinerary, itinerary.endTime - NINETY_SECONDS)
6772
const params = {
6873
date: newEndTime.format(OTP_API_DATE_FORMAT),
6974
departArrive: 'ARRIVE',
70-
startTransitStopId: getFirstStopId(itinerary),
7175
time: newEndTime.format(OTP_API_TIME_FORMAT)
7276
}
77+
if (!getState().otp?.config?.api?.v2) {
78+
params.startTransitStopId = getFirstStopId(itinerary)
79+
}
7380
dispatch(updateParamsAndPlan(params))
7481
}
7582
}
@@ -78,16 +85,22 @@ export function planPrevious () {
7885
* Plan the next trip, setting the depart at time to the current itinerary's
7986
* start time (plus a small amount).
8087
*/
81-
export function planNext () {
88+
export function planNext() {
8289
return function (dispatch, getState) {
8390
const itinerary = getActiveItinerary(getState())
84-
const newStartTime = offsetTime(itinerary, itinerary.startTime + NINETY_SECONDS)
91+
const newStartTime = offsetTime(
92+
itinerary,
93+
itinerary.startTime + NINETY_SECONDS
94+
)
8595
const params = {
8696
date: newStartTime.format(OTP_API_DATE_FORMAT),
8797
departArrive: 'DEPART',
88-
startTransitStopId: getFirstStopId(itinerary),
8998
time: newStartTime.format(OTP_API_TIME_FORMAT)
9099
}
100+
if (!getState().otp?.config?.api?.v2) {
101+
params.startTransitStopId = getFirstStopId(itinerary)
102+
}
103+
91104
dispatch(updateParamsAndPlan(params))
92105
}
93106
}
@@ -96,17 +109,22 @@ export function planNext () {
96109
* Plan the last trip of the day, or if the last trip has already been planned,
97110
* plan the last trip of the next day.
98111
*/
99-
export function planLast () {
112+
export function planLast() {
100113
return function (dispatch, getState) {
101114
const state = getState()
102115
const itinerary = getActiveItinerary(state)
103-
const {currentQuery} = state.otp
116+
const { currentQuery } = state.otp
104117
const params = {
105-
date: moment(currentQuery.date).add('days', 1).format(OTP_API_DATE_FORMAT),
118+
date: moment(currentQuery.date)
119+
.add('days', 1)
120+
.format(OTP_API_DATE_FORMAT),
106121
departArrive: 'ARRIVE',
107-
startTransitStopId: getFirstStopId(itinerary),
108122
time: SERVICE_BREAK
109123
}
124+
if (!state.otp?.config?.api?.v2) {
125+
params.startTransitStopId = getFirstStopId(itinerary)
126+
}
127+
110128
dispatch(updateParamsAndPlan(params))
111129
}
112130
}

Diff for: lib/components/app/call-taker-panel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class CallTakerPanel extends Component {
181181
locationType="to"
182182
onLocationCleared={this._removePlace}
183183
// FIXME: function def
184-
onLocationSelected={(result) => this._addPlace(result, i)}
184+
onLocationSelected={(_, result) => this._addPlace(result, i)}
185185
showClearButton={!mobile}
186186
/>
187187
)

0 commit comments

Comments
 (0)