Skip to content

Commit e97b58f

Browse files
committed
refactor: address PR #162 comments
1 parent 6ecb299 commit e97b58f

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

Diff for: lib/actions/ui.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,7 @@ export function matchContentToUrl (location) {
7878
dispatch(setMapCenter({ lat, lon }))
7979
dispatch(setMapZoom({ zoom }))
8080
// If router ID is provided, override the default routerId.
81-
if (routerId) {
82-
// This is a somewhat hidden element of the trip planner, so show a
83-
// confirmation message to the user to ensure they are aware of what
84-
// is happening.
85-
const useAltRouterId = window.confirm(
86-
`The trip planner's router is set to ${routerId}.\n\nClick OK to confirm or Cancel to use the default router.\n\nNote: new sessions opened with URLs copied from this tab's address bar will not reference the correct router (must contain the #/start/lat/lon/zoom/router prefix).`
87-
)
88-
if (useAltRouterId) dispatch(setRouterId(routerId))
89-
else dispatch(setRouterId(null))
90-
}
81+
if (routerId) dispatch(setRouterId(routerId))
9182
dispatch(setMainPanelContent(null))
9283
break
9384
// For any other route path, just revert to default panel.

Diff for: lib/reducers/create-otp-reducer.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ export function getInitialState (userDefinedConfig, initialQuery) {
128128
// Note: this mechanism assumes that the OTP API path is otp/routers/default.
129129
const routerId = window.sessionStorage.getItem('routerId')
130130
// If routerId is found, update the config.api.path (keep the original config
131-
// value at _path in case it needs to be reverted.)
131+
// value at originalPath in case it needs to be reverted.)
132132
if (routerId) {
133-
config.api._path = userDefinedConfig.api.path
133+
config.api.originalPath = userDefinedConfig.api.path
134134
config.api.path = `/otp/routers/${routerId}`
135135
}
136136
let queryModes = currentQuery.mode.split(',')
@@ -555,13 +555,13 @@ function createOtpReducer (config, initialQuery) {
555555
})
556556
case 'SET_ROUTER_ID':
557557
const routerId = action.payload
558-
// Store original path value in _path variable.
559-
const _path = config.api._path || config.api.path || '/otp/routers/default'
558+
// Store original path value in originalPath variable.
559+
const originalPath = config.api.originalPath || config.api.path || '/otp/routers/default'
560560
const path = routerId
561561
? `/otp/routers/${routerId}`
562562
// If routerId is null, revert to the original config's API path (or
563563
// the standard path if that is not found).
564-
: _path
564+
: originalPath
565565
// Store routerId in session storage (persists through page reloads but
566566
// not when a new tab/window is opened).
567567
if (routerId) window.sessionStorage.setItem('routerId', routerId)
@@ -570,7 +570,7 @@ function createOtpReducer (config, initialQuery) {
570570
config: {
571571
api: {
572572
path: { $set: path },
573-
_path: { $set: _path }
573+
originalPath: { $set: originalPath }
574574
}
575575
}
576576
})

0 commit comments

Comments
 (0)