From 12edae7210d7ff4f07c18286e37b3f8dfb25a81a Mon Sep 17 00:00:00 2001 From: Scott Feeney Date: Wed, 24 Jan 2024 22:46:34 -0800 Subject: [PATCH] Honor limited connecting modes when location dragged there were a few cases where i overlooked passing this thru. --- src/features/routeParams.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/features/routeParams.js b/src/features/routeParams.js index 3317f403..1a09cad5 100644 --- a/src/features/routeParams.js +++ b/src/features/routeParams.js @@ -209,17 +209,6 @@ export function locationsSubmitted() { connectingModes, } = getState().routeParams; - const blockRouteTypes = []; - for (const modeCategory of Object.values(TransitModes.CATEGORIES)) { - if (!connectingModes.includes(modeCategory)) { - for (const modeInCategory of TransitModes.CATEGORY_TO_MODES[ - modeCategory - ]) { - blockRouteTypes.push(modeInCategory); - } - } - } - const hydrate = async function hydrate(text, location, startOrEnd) { // Decide whether to use the text or location: let useLocation = false; @@ -329,7 +318,7 @@ export function locationsSubmitted() { resultingEndLocation.point.geometry.coordinates, arriveBy, initialTime, - blockRouteTypes, + _computeBlockRouteTypes(connectingModes), )(dispatch, getState); } }; @@ -344,13 +333,15 @@ export function locationDragged(startOrEnd, coords) { }); // If we have a location for the other point, fetch a route. - let { start, end, arriveBy, initialTime } = getState().routeParams; + let { start, end, arriveBy, initialTime, connectingModes } = + getState().routeParams; if (startOrEnd === 'start' && end?.point?.geometry.coordinates) { await fetchRoute( coords, end.point.geometry.coordinates, arriveBy, initialTime, + _computeBlockRouteTypes(connectingModes), )(dispatch, getState); } else if (startOrEnd === 'end' && start?.point?.geometry.coordinates) { await fetchRoute( @@ -358,6 +349,7 @@ export function locationDragged(startOrEnd, coords) { coords, arriveBy, initialTime, + _computeBlockRouteTypes(connectingModes), )(dispatch, getState); } }; @@ -374,13 +366,15 @@ export function locationSelectedOnMap(startOrEnd, coords) { }); // If we have a location for the other point, fetch a route. - let { start, end, arriveBy, initialTime } = getState().routeParams; + let { start, end, arriveBy, initialTime, connectingModes } = + getState().routeParams; if (startOrEnd === 'start' && end?.point?.geometry.coordinates) { await fetchRoute( coords, end.point.geometry.coordinates, arriveBy, initialTime, + _computeBlockRouteTypes(connectingModes), )(dispatch, getState); } else if (startOrEnd === 'end' && start?.point?.geometry.coordinates) { await fetchRoute( @@ -388,6 +382,7 @@ export function locationSelectedOnMap(startOrEnd, coords) { coords, arriveBy, initialTime, + _computeBlockRouteTypes(connectingModes), )(dispatch, getState); } }; @@ -521,3 +516,17 @@ export function changeConnectingModes(newConnectingModes) { dispatch(locationsSubmitted()); }; } + +function _computeBlockRouteTypes(connectingModes) { + const blockRouteTypes = []; + for (const modeCategory of Object.values(TransitModes.CATEGORIES)) { + if (!connectingModes.includes(modeCategory)) { + for (const modeInCategory of TransitModes.CATEGORY_TO_MODES[ + modeCategory + ]) { + blockRouteTypes.push(modeInCategory); + } + } + } + return blockRouteTypes; +}