diff --git a/app/component/itinerary/ItineraryDetails.js b/app/component/itinerary/ItineraryDetails.js index 9b679f6209..8e92712666 100644 --- a/app/component/itinerary/ItineraryDetails.js +++ b/app/component/itinerary/ItineraryDetails.js @@ -53,7 +53,7 @@ class ItineraryDetails extends React.Component { currentLanguage: PropTypes.string, changeHash: PropTypes.func, openSettings: PropTypes.func.isRequired, - setNavigation: PropTypes.func, + startNavigation: PropTypes.func, bikeAndPublicItineraryCount: PropTypes.number, relayEnvironment: relayShape, }; @@ -65,7 +65,7 @@ class ItineraryDetails extends React.Component { bikeAndPublicItineraryCount: 0, carEmissions: undefined, relayEnvironment: undefined, - setNavigation: undefined, + startNavigation: undefined, }; static contextTypes = { @@ -308,11 +308,10 @@ class ItineraryDetails extends React.Component { /> )), - this.props.setNavigation && ( + this.props.startNavigation && ( ), config.showCO2InItinerarySummary && !legsWithScooter && ( diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index 2af4f9ea6c..e32777aeef 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -17,6 +17,7 @@ import { getDialogState, getLatestNavigatorItinerary, setDialogState, + setLatestNavigatorItinerary, } from '../../store/localStorage'; import { addAnalyticsEvent } from '../../util/analyticsUtils'; import { getWeatherData } from '../../util/apiUtils'; @@ -654,6 +655,21 @@ export default function ItineraryPage(props, context) { setNaviMode(isEnabled); }; + const storeItineraryAndStartNavigation = itinerary => { + setNavigation(true); + setLatestNavigatorItinerary({ + itinerary, + params: { + from: params.from, + to: params.to, + arriveBy: query.arriveBy, + time: query.time, + hash, + secondHash, + }, + }); + }; + // save url-defined location to old searches function saveUrlSearch(endpoint) { const parts = endpoint.split('::'); // label::lat,lon @@ -1164,7 +1180,10 @@ export default function ItineraryPage(props, context) { Date.parse(combinedEdges[selectedIndex]?.node.end) < Date.now(); const navigateHook = !desktop && config.experimental.navigation && !pastSearch - ? setNavigation + ? () => + storeItineraryAndStartNavigation( + combinedEdges[selectedIndex]?.node, + ) : undefined; carEmissions = carEmissions ? Math.round(carEmissions) : undefined; content = ( @@ -1180,7 +1199,7 @@ export default function ItineraryPage(props, context) { bikeAndPublicItineraryCount={bikePublicPlan.bikePublicItineraryCount} openSettings={showSettingsPanel} relayEnvironment={props.relayEnvironment} - setNavigation={navigateHook} + startNavigation={navigateHook} /> ); } diff --git a/app/component/itinerary/StartNavi.js b/app/component/itinerary/StartNavi.js index 8fd7fe8471..1b30f29760 100644 --- a/app/component/itinerary/StartNavi.js +++ b/app/component/itinerary/StartNavi.js @@ -1,35 +1,18 @@ -import { matchShape } from 'found'; import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage, intlShape } from 'react-intl'; -import { setLatestNavigatorItinerary } from '../../store/localStorage'; -import { configShape, itineraryShape } from '../../util/shapes'; +import { configShape } from '../../util/shapes'; import Icon from '../Icon'; -const StartNavi = ({ setNavigation, itinerary }, context) => { - const { config, intl, match } = context; +const StartNavi = ({ startNavigation }, context) => { + const { config, intl } = context; const color = config.colors?.accessiblePrimary || config.colors?.primary || 'black'; - const handleClick = () => { - setNavigation(true); - setLatestNavigatorItinerary({ - itinerary, - params: { - from: match.params.from, - to: match.params.to, - arriveBy: match.location.query.arriveBy, - time: match.location.query.time, - hash: match.params.hash, - secondHash: match.params.secondHash, - }, - }); - }; - return (
-