From 1352f8c44c5434cf880a34ca1b7a293cbefa20a1 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 20 Nov 2024 14:38:31 +0200 Subject: [PATCH 01/11] fix: remove unused context --- app/component/RentalVehiclePageMapContainer.js | 10 ---------- app/component/StopPageMapContainer.js | 5 ----- 2 files changed, 15 deletions(-) diff --git a/app/component/RentalVehiclePageMapContainer.js b/app/component/RentalVehiclePageMapContainer.js index f9a24aae05..d5105aa31a 100644 --- a/app/component/RentalVehiclePageMapContainer.js +++ b/app/component/RentalVehiclePageMapContainer.js @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import React from 'react'; import { createFragmentContainer, graphql } from 'react-relay'; import { FormattedMessage } from 'react-intl'; @@ -18,15 +17,6 @@ const RentalVehiclePageMapContainer = ({ rentalVehicle }) => { return ; }; -RentalVehiclePageMapContainer.contextTypes = { - config: PropTypes.shape({ - map: PropTypes.shape({ - tileSize: PropTypes.number, - zoom: PropTypes.number, - }), - }), -}; - RentalVehiclePageMapContainer.propTypes = { rentalVehicle: rentalVehicleShape, }; diff --git a/app/component/StopPageMapContainer.js b/app/component/StopPageMapContainer.js index a10931d8c2..917e98612e 100644 --- a/app/component/StopPageMapContainer.js +++ b/app/component/StopPageMapContainer.js @@ -1,7 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { createFragmentContainer, graphql } from 'react-relay'; -import { configShape } from '../util/shapes'; import StopPageMap from './map/StopPageMap'; function StopPageMapContainer({ stop }) { @@ -12,10 +11,6 @@ function StopPageMapContainer({ stop }) { return ; } -StopPageMapContainer.contextTypes = { - config: configShape.isRequired, -}; - StopPageMapContainer.propTypes = { stop: PropTypes.shape({ lat: PropTypes.number.isRequired, From 37dba4a80a84906065b42204b587f06cf2edcb70 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Thu, 21 Nov 2024 09:13:16 +0200 Subject: [PATCH 02/11] chore: reset zoom --- app/component/itinerary/ItineraryPage.js | 8 +++++--- app/component/map/MapWithTracking.js | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index e32777aeef..eed2eaec1e 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -115,6 +115,8 @@ const emptyState = { const emptyPlan = { plan: {}, loading: LOADSTATE.DONE }; const unset = { plan: {}, loading: LOADSTATE.UNSET }; +const noFocus = { center: undefined, zoom: undefined, bounds: undefined }; + export default function ItineraryPage(props, context) { const headerRef = useRef(null); const mwtRef = useRef(); @@ -648,7 +650,7 @@ export default function ItineraryPage(props, context) { mobileRef.current.setBottomSheet(isEnabled ? 'bottom' : 'middle'); } if (!isEnabled) { - setMapState({ center: undefined, zoom: undefined, bounds: undefined }); + setMapState(noFocus); navigateMap(); clearLatestNavigatorItinerary(); } @@ -798,7 +800,7 @@ export default function ItineraryPage(props, context) { useEffect(() => { navigateMap(); - setMapState({ center: undefined, zoom: undefined, bounds: undefined }); + setMapState(noFocus); if (detailView) { // If itinerary is not found in detail view, go back to summary view @@ -913,7 +915,7 @@ export default function ItineraryPage(props, context) { ) .filter(a => a[0] && a[1]), ); - setMapState({ bounds, center: undefined }); + setMapState({ bounds, center: undefined, zoom: undefined }); }; const changeHash = index => { diff --git a/app/component/map/MapWithTracking.js b/app/component/map/MapWithTracking.js index 8551ebbed8..21a76bccfa 100644 --- a/app/component/map/MapWithTracking.js +++ b/app/component/map/MapWithTracking.js @@ -280,6 +280,7 @@ class MapWithTrackingStateHandler extends React.Component { (!isEqual(this.oldBounds, this.props.bounds) || this.refresh) ) { this.naviProps.bounds = cloneDeep(this.props.bounds); + delete this.naviProps.zoom; if (this.refresh) { // bounds is defined by [min, max] point pair. Substract min lat a bit this.naviProps.bounds[0][0] -= 0.000001 * Math.random(); From 2c330891ad107de3f312355dbc2c355cd8af2c51 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Fri, 22 Nov 2024 08:01:49 +0200 Subject: [PATCH 03/11] chore: remove unused context --- app/component/map/ItineraryLine.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/component/map/ItineraryLine.js b/app/component/map/ItineraryLine.js index b0a7e7a51b..dcb73a9336 100644 --- a/app/component/map/ItineraryLine.js +++ b/app/component/map/ItineraryLine.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import polyUtil from 'polyline-encoded'; import React from 'react'; -import { intlShape } from 'react-intl'; import { isBrowser } from '../../util/browser'; import { getMiddleOf } from '../../util/geo-utils'; import { @@ -23,7 +22,6 @@ import SpeechBubble from './SpeechBubble'; class ItineraryLine extends React.Component { static contextTypes = { config: configShape.isRequired, - intl: intlShape.isRequired, }; static propTypes = { From fba47e42e5845432da447f465af56246bb577bb4 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Fri, 22 Nov 2024 08:44:17 +0200 Subject: [PATCH 04/11] fix: remove dead parameter --- app/component/map/ItineraryLine.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/component/map/ItineraryLine.js b/app/component/map/ItineraryLine.js index dcb73a9336..f4edf1c338 100644 --- a/app/component/map/ItineraryLine.js +++ b/app/component/map/ItineraryLine.js @@ -71,7 +71,6 @@ class ItineraryLine extends React.Component { { mode: leg.mode, type: leg.route?.type, - gtfsId: leg.route?.gtfsId, }, this.context.config, ); From 9014839bf902d7f212e9479aff33e020a9be6561 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Fri, 22 Nov 2024 08:59:39 +0200 Subject: [PATCH 05/11] fix: remove unused query components --- app/component/map/WalkQuery.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/component/map/WalkQuery.js b/app/component/map/WalkQuery.js index 826e9e8aae..0559deeffa 100644 --- a/app/component/map/WalkQuery.js +++ b/app/component/map/WalkQuery.js @@ -100,21 +100,12 @@ const walkQuery = graphql` platformCode } } - trip { - stoptimes { - stop { - gtfsId - } - pickupType - } - } intermediatePlaces { stop { gtfsId lat lon name - code platformCode } } From 61cf0cfdc2314397b831e0e8b6ba7503e6196890 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Fri, 22 Nov 2024 13:06:50 +0200 Subject: [PATCH 06/11] fix: pass mobile prop to search target config utility --- app/component/itinerary/OriginDestinationBar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/component/itinerary/OriginDestinationBar.js b/app/component/itinerary/OriginDestinationBar.js index 4995bec2ff..05d0f22e7b 100644 --- a/app/component/itinerary/OriginDestinationBar.js +++ b/app/component/itinerary/OriginDestinationBar.js @@ -159,7 +159,7 @@ class OriginDestinationBar extends React.Component { 'Datasource', props.showFavourites ? 'Favourite' : '', ]} - targets={getLocationSearchTargets(config, false)} + targets={getLocationSearchTargets(config, props.isMobile)} lang={props.language} disableAutoFocus={props.isMobile} isMobile={props.isMobile} From 1b527a1e2308a64ecae581e886547e8ce17648d2 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 25 Nov 2024 15:15:58 +0200 Subject: [PATCH 07/11] fix: remove unnecessary eslint disable --- app/component/map/MapWithTracking.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/component/map/MapWithTracking.js b/app/component/map/MapWithTracking.js index 21a76bccfa..5deda71efb 100644 --- a/app/component/map/MapWithTracking.js +++ b/app/component/map/MapWithTracking.js @@ -16,7 +16,6 @@ import { isBrowser } from '../../util/browser'; import PositionStore from '../../store/PositionStore'; import { mapLayerShape } from '../../store/MapLayerStore'; import BubbleDialog from '../BubbleDialog'; -// eslint-disable-next-line import/no-named-as-default import PreferencesStore from '../../store/PreferencesStore'; import MapLayersDialogContent from '../MapLayersDialogContent'; import MenuDrawer from '../MenuDrawer'; From c3c0663d478fcfddcd5f2f79bbc06503c2f3052f Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 25 Nov 2024 15:23:47 +0200 Subject: [PATCH 08/11] fix: no need to call mapRef callback twice --- app/component/map/Map.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/component/map/Map.js b/app/component/map/Map.js index 890a7fd11d..e8e97cd970 100644 --- a/app/component/map/Map.js +++ b/app/component/map/Map.js @@ -141,9 +141,6 @@ export default class Map extends React.Component { startClient(this.context); } this.updateZoom(); - if (this.props.mapRef) { - this.props.mapRef(this); - } } // eslint-disable-next-line camelcase From e7b9886285945df6a33295f76c42a37a45f25f19 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 25 Nov 2024 15:27:06 +0200 Subject: [PATCH 09/11] fix: force rerendering after bounds change in itinerary page --- app/component/itinerary/ItineraryPage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index b2d86fe9e2..d37c787ec6 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -815,6 +815,7 @@ export default function ItineraryPage(props, context) { // turn off tracking when user navigates away from tracking view setNavigation(false); } + setTimeout(() => mwtRef.current?.map?.updateZoom(), 1); }, [hash, secondHash]); useEffect(() => { @@ -920,6 +921,7 @@ export default function ItineraryPage(props, context) { .filter(a => a[0] && a[1]), ); setMapState({ bounds, center: undefined, zoom: undefined }); + setTimeout(() => mwtRef.current?.map?.updateZoom(), 1); }; const changeHash = index => { From 62d0f6a93f63954211c0f30f2af441f85f1e2ade Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 25 Nov 2024 15:28:32 +0200 Subject: [PATCH 10/11] fix: actively update zoom after bounds change in stopsnearyou map --- app/component/map/NearYouMap.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/component/map/NearYouMap.js b/app/component/map/NearYouMap.js index 1b0204c275..d5e5a7c450 100644 --- a/app/component/map/NearYouMap.js +++ b/app/component/map/NearYouMap.js @@ -141,6 +141,7 @@ function NearYouMap( position, showWalkRoute, prioritizedStopsNearYou, + setMWTRef, ...rest }, { ...context }, @@ -153,6 +154,7 @@ function NearYouMap( const [walk, setWalk] = useState({ itinerary: null, stop: null }); const prevPlace = useRef(); const prevMode = useRef(); + const mwtRef = useRef(); const { mode } = match.params; const isTransitMode = mode !== 'CITYBIKE'; const walkRoutingThreshold = @@ -209,6 +211,15 @@ function NearYouMap( } }; + // get ref to MapWithTracking.js + const setMWTRefNearYou = ref => { + mwtRef.current = ref; + if (setMWTRef) { + // forward to parent component + setMWTRef(ref); + } + }; + useEffect(() => { prevPlace.current = match.params.place; prevMode.current = match.params.mode; @@ -221,6 +232,7 @@ function NearYouMap( const newBounds = handleBounds(position, sortedStopEdges); if (newBounds.length > 0) { setBounds(newBounds); + setTimeout(() => mwtRef.current?.map.updateZoom(), 1); } }, [position, sortedStopEdges]); @@ -395,6 +407,7 @@ function NearYouMap( bounds, leafletObjs, breakpoint, + setMWTRef: setMWTRefNearYou, ...rest, }; @@ -436,6 +449,7 @@ NearYouMap.propTypes = { relay: relayShape.isRequired, loading: PropTypes.bool, showWalkRoute: PropTypes.bool, + setMWTRef: PropTypes.func, }; NearYouMap.defaultProps = { @@ -443,6 +457,7 @@ NearYouMap.defaultProps = { showWalkRoute: false, loading: false, favouriteIds: undefined, + setMWTRef: undefined, prioritizedStopsNearYou: [], }; From ce36765ded4ffa4586f98ff13573f08888da53d8 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Mon, 25 Nov 2024 15:29:29 +0200 Subject: [PATCH 11/11] chore: remove a couple of dead css variables --- sass/themes/default/_theme.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/sass/themes/default/_theme.scss b/sass/themes/default/_theme.scss index 4ebcc77e15..ce9e027acc 100644 --- a/sass/themes/default/_theme.scss +++ b/sass/themes/default/_theme.scss @@ -28,7 +28,6 @@ $background-color-lighter: #f4f4f5; $primary-color: $livi-blue; $primary-font-color: $white; $secondary-color: #008bde; -$secondary-font-color: $white; $favourite-color: $livi-gold; $hilight-color: $livi-blue; $action-color: $secondary-color; @@ -38,7 +37,6 @@ $cancelation-background: #fbe0ea; $disruption-color: $cancelation-red; $banner-disruption-color: $disruption-color; $realtime-color: #46850e; -$visited-link-color: #8c4799; $current-location-color: $primary-color; $desktop-title-color: $primary-color; $desktop-title-arrow-icon-color: $secondary-color;