From fe69e4746c144bcb42742af6cdaefc9115552c80 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:26:14 -0500 Subject: [PATCH 1/7] chore(deps): Update itinerary-body pkg and deduplicate deps. --- package.json | 2 +- yarn.lock | 106 +++++++++------------------------------------------ 2 files changed, 19 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index 79c052fed..f211c743e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@opentripplanner/humanize-distance": "^1.2.0", "@opentripplanner/icons": "3.0.1", "@opentripplanner/location-field": "3.1.1", - "@opentripplanner/itinerary-body": "6.1.0", + "@opentripplanner/itinerary-body": "6.1.1", "@opentripplanner/location-icon": "^1.4.1", "@opentripplanner/map-popup": "5.1.1", "@opentripplanner/otp2-tile-overlay": "2.1.1", diff --git a/yarn.lock b/yarn.lock index 1c1df6718..6da47bb4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2403,7 +2403,7 @@ maplibre-gl "^2.1.9" react-map-gl "^7.0.15" -"@opentripplanner/building-blocks@2.1.0": +"@opentripplanner/building-blocks@2.1.0", "@opentripplanner/building-blocks@^2.0.0": version "2.1.0" resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-2.1.0.tgz#20d688dbc7a152256f571562199981099bde7820" integrity sha512-Vnc/W2EGybIbzXXofthGVW8HN1o5ThW1+XjWquVlKlSb2xxruWscstz9frOWlbHg239SEdTpZUuaARwMWflVaA== @@ -2415,12 +2415,7 @@ resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.2.3.tgz#404e8f9038867d66d55f51adf8855b1326c51ed5" integrity sha512-I0AxiZrTZu+e7+av4u0tHW2ijqpxH0AkLHrhf75BHf1Ep2FOGxaul/v+8UT18mNYiM5eHNstOX3XiXaDjtCUaw== -"@opentripplanner/building-blocks@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-2.0.0.tgz#8282c01dff7db5c7e809f6ea91cb52df559a2f9d" - integrity sha512-N07rDaZL8fp552eI9/0j1udKjc0uOpvO0Wv1P19Ge0a4roques463MJgWJ026fbopRCi3uwbc/gYTlh4/ske9A== - -"@opentripplanner/core-utils@12.0.1": +"@opentripplanner/core-utils@12.0.1", "@opentripplanner/core-utils@^12.0.0": version "12.0.1" resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.1.tgz#2bafb78133393213b4943c76fec5d46436c0fb6d" integrity sha512-QUTxEcpiOnbqaoiu6RQngTLlQHjSHO4PCMJqR9IRiaei08FnlTx2jgpvIaRla6u7tRNr12YCzptc37+a10ryww== @@ -2456,24 +2451,6 @@ lodash.isequal "^4.5.0" qs "^6.9.1" -"@opentripplanner/core-utils@^12.0.0": - version "12.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.0.tgz#cc40af92620b207f4dce817d08f99def0cdaea7a" - integrity sha512-udLF8XU+k7gxZ+yyyw7ASz6/4D540zYIv8a9GbUL61TF8HmgGhcMk3XOgBnm5jdOukuaNNpOFE4J3oJc5QsSBQ== - dependencies: - "@conveyal/lonlat" "^1.4.1" - "@mapbox/polyline" "^1.1.0" - "@opentripplanner/geocoder" "^3.0.2" - "@styled-icons/foundation" "^10.34.0" - "@turf/along" "^6.0.1" - chroma-js "^2.4.2" - date-fns "^2.28.0" - date-fns-tz "^1.2.2" - graphql "^16.6.0" - lodash.clonedeep "^4.5.0" - lodash.isequal "^4.5.0" - qs "^6.9.1" - "@opentripplanner/endpoints-overlay@3.0.1": version "3.0.1" resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-3.0.1.tgz#b6b8e2f08ae41fbaad475fc0f0fe3e72d7d36463" @@ -2518,7 +2495,7 @@ resolved "https://registry.yarnpkg.com/@opentripplanner/humanize-distance/-/humanize-distance-1.2.0.tgz#71cf5d5d1b756adef15300edbba0995ccd4b35ee" integrity sha512-x0QRXMDhypFeazZ6r6vzrdU8vhiV56nZ/WX6zUbxpgp6T9Oclw0gwR2Zdw6DZiiFpSYVNeVNxVzZwsu6NRGjcA== -"@opentripplanner/icons@3.0.1": +"@opentripplanner/icons@3.0.1", "@opentripplanner/icons@^3.0.0": version "3.0.1" resolved "https://registry.yarnpkg.com/@opentripplanner/icons/-/icons-3.0.1.tgz#62cf5ffd9ad42c5ba2ac64cf91e9f10c8300ff1e" integrity sha512-pu96GWVR2ef6aMPPJRjdzHkIVlENGa3LRlqNaW3PEZQLjycsCsT1ZpJ6+zKwVfZsgoMl1L8mx2qjLO4RUZzGAA== @@ -2534,18 +2511,10 @@ "@opentripplanner/core-utils" "^11.4.4" prop-types "^15.7.2" -"@opentripplanner/icons@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/icons/-/icons-3.0.0.tgz#f7293fd4dd2625eace3a4c82ecd573d6000d85d3" - integrity sha512-naSCdCsPwSyEiP7Vf6oN6dpgwpFIkeQFXfTJG7lp1Dg9emLTAYzRx/f+45e9Bh0zP0aA4DsN4VgHBQllyu82qQ== - dependencies: - "@opentripplanner/core-utils" "^11.4.4" - prop-types "^15.7.2" - -"@opentripplanner/itinerary-body@6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/itinerary-body/-/itinerary-body-6.1.0.tgz#8a1399e8dc15b6918ede51a0f263519e4b891415" - integrity sha512-nv42+hJavdVS5nHtKLDv1Um04patzGD+/xh3zApgxpB9xG/D2Zy4JBqbyMtZ1eHKF4JYkmm+NsAq/7043WPXGA== +"@opentripplanner/itinerary-body@6.1.1", "@opentripplanner/itinerary-body@^6.0.0": + version "6.1.1" + resolved "https://registry.yarnpkg.com/@opentripplanner/itinerary-body/-/itinerary-body-6.1.1.tgz#7b7b2af038a683f785d43245c336180f1b324436" + integrity sha512-ULMwZSGBkAGtuJfBO7vjtTEsXvS06l65FSMTcxarY1322G7dvFUMOKmMJ626EdwCGUcw9J1R7JfS0uV3uUv2Ag== dependencies: "@opentripplanner/core-utils" "^12.0.0" "@opentripplanner/humanize-distance" "^1.2.0" @@ -2582,24 +2551,6 @@ version "3.1.1" resolved "https://registry.yarnpkg.com/@opentripplanner/location-field/-/location-field-3.1.1.tgz#0658df4cfd47866153c8ae33fd60e991cdf94df0" integrity sha512-Q9yhi3AVlnj8izrpJvxN+uVBjjtEDyFXUsJ0VhE9zevVpGzCh/gcGNzJY5EnP2IRDd/Szx6dPUogt3XJlHkHTQ== - -"@opentripplanner/itinerary-body@^6.0.0": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@opentripplanner/itinerary-body/-/itinerary-body-6.0.3.tgz#84573d20ac9cc1fc7f2d2e032fac5a072ac3e142" - integrity sha512-1qrH8hpR5Rr9KMGNnajI7GJyuoV+rogmyGqd5Z5DErZGp4luVzksIsnyW1IbxRslnV3bqKll+DH8lTXy4QIyZg== - dependencies: - "@opentripplanner/core-utils" "^12.0.0" - "@opentripplanner/humanize-distance" "^1.2.0" - "@opentripplanner/icons" "^3.0.0" - "@opentripplanner/location-icon" "^1.4.1" - "@styled-icons/fa-solid" "^10.34.0" - "@styled-icons/foundation" "^10.34.0" - date-fns "^2.28.0" - date-fns-tz "^1.2.2" - flat "^5.0.2" - react-animate-height "^3.0.4" - react-resize-detector "^4.2.1" - string-similarity "^4.0.4" dependencies: "@conveyal/geocoder-arcgis-geojson" "^0.0.3" "@opentripplanner/core-utils" "^12.0.0" @@ -2617,7 +2568,7 @@ "@styled-icons/fa-regular" "^10.34.0" "@styled-icons/fa-solid" "^10.34.0" -"@opentripplanner/map-popup@5.1.1": +"@opentripplanner/map-popup@5.1.1", "@opentripplanner/map-popup@^v5.1.0": version "5.1.1" resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-5.1.1.tgz#f4699b63a2ba0fae6263f2417c5b85f5ffc204cb" integrity sha512-HifqZFmrBy3FmARVKZwUnad8U/L8ftBm2PcSck4oGQ768E7TKhqyzXz+GzkO39TyKNU5yiNgmQEbss8elZuJ/g== @@ -2639,17 +2590,6 @@ "@opentripplanner/from-to-location-picker" "^2.1.14" flat "^5.0.2" -"@opentripplanner/map-popup@^v5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-5.1.0.tgz#cf6374bf7b69af69c026ec414a84719078c56e9e" - integrity sha512-EShoMyFZa7Zb2ZZrJhEsJfuCAvs2jfQe5QstU+AEk5Jm1zc8LzU6PsXmizQ/RMVi6zIYLhlBoZ3u458tTA3VQA== - dependencies: - "@opentripplanner/base-map" "^4.0.0" - "@opentripplanner/building-blocks" "^2.0.0" - "@opentripplanner/core-utils" "^12.0.0" - "@opentripplanner/from-to-location-picker" "^3.0.0" - flat "^5.0.2" - "@opentripplanner/otp2-tile-overlay@2.1.1": version "2.1.1" resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-2.1.1.tgz#3bd2f26caa01181eb4ca90bbd05ce784f9b05a7a" @@ -4329,9 +4269,9 @@ acorn@^7.0.0, acorn@^7.1.0, acorn@^7.1.1, acorn@^7.4.0: integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== acorn@^8.2.4: - version "8.4.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" - integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== + version "8.14.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0" + integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA== address@1.1.2, address@^1.0.1: version "1.1.2" @@ -15617,17 +15557,7 @@ react-transition-group@^2.0.0, react-transition-group@^2.2.0: prop-types "^15.6.2" react-lifecycles-compat "^3.0.4" -react-transition-group@^4.3.0: - version "4.4.2" - resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.2.tgz#8b59a56f09ced7b55cbd53c36768b922890d5470" - integrity sha512-/RNYfRAMlZwDSr6z4zNKV6xu53/e2BuaBbGhbyYIXTrmgu/bGHzmqOs7mJSJBHy9Ud+ApHx3QjrkKSp1pxvlFg== - dependencies: - "@babel/runtime" "^7.5.5" - dom-helpers "^5.0.1" - loose-envify "^1.4.0" - prop-types "^15.6.2" - -react-transition-group@^4.4.5: +react-transition-group@^4.3.0, react-transition-group@^4.4.5: version "4.4.5" resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.5.tgz#e53d4e3f3344da8521489fbef8f2581d42becdd1" integrity sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g== @@ -17712,11 +17642,6 @@ throat@^6.0.1: resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" integrity sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w== -throttle-debounce@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-2.3.0.tgz#fd31865e66502071e411817e241465b3e9c372e2" - integrity sha512-H7oLPV0P7+jgvrk+6mwwwBDmxTaxnu9HMXmloNLXwnNO0ZxZ31Orah2n8lU1eMPvsaowP2CX+USCgyovXfdOFQ== - through2@^2.0.0, through2@~2.0.0, through2@~2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" @@ -19036,7 +18961,7 @@ write-file-atomic@^3.0.0, write-file-atomic@^3.0.3: signal-exit "^3.0.2" typedarray-to-buffer "^3.1.5" -ws@7.4.6, ws@^7.4.6: +ws@7.4.6: version "7.4.6" resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== @@ -19048,6 +18973,11 @@ ws@^6.2.1: dependencies: async-limiter "~1.0.0" +ws@^7.4.6: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + ws@^8.0.0: version "8.5.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" From e8e4b6849be8f28a3f652bb967511361d8c6ce4d Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:52:09 -0500 Subject: [PATCH 2/7] chore(deps): Update yarn.lock --- yarn.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yarn.lock b/yarn.lock index 6da47bb4b..1f29a0b0f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17642,6 +17642,11 @@ throat@^6.0.1: resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" integrity sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w== +throttle-debounce@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-2.3.0.tgz#fd31865e66502071e411817e241465b3e9c372e2" + integrity sha512-H7oLPV0P7+jgvrk+6mwwwBDmxTaxnu9HMXmloNLXwnNO0ZxZ31Orah2n8lU1eMPvsaowP2CX+USCgyovXfdOFQ== + through2@^2.0.0, through2@~2.0.0, through2@~2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" From 142db3fffd5c290c96c1d5fb974027c27c4cb1d3 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:17:04 -0600 Subject: [PATCH 3/7] Only update currentPosition if the user has moved --- lib/components/app/responsive-webapp.js | 50 ++++++++++++++++++------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index ee4c3c684..2d9c165b6 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -55,6 +55,23 @@ class ResponsiveWebapp extends Component { /** Lifecycle methods **/ + // Check if the position has changed enough to update the currentPosition + // (prevent constant updates in nearby view) + positionShouldUpdate = (position) => { + const { currentPosition } = this.props + if (!currentPosition.coords) return true + const latChanged = + Math.abs( + position?.coords?.latitude - currentPosition?.coords?.latitude + ) >= 0.001 + const lonChanged = + Math.abs( + position?.coords?.longitude - currentPosition?.coords?.longitude + ) >= 0.001 + + return latChanged || lonChanged + } + /* eslint-disable-next-line complexity */ componentDidUpdate(prevProps) { const { @@ -69,6 +86,7 @@ class ResponsiveWebapp extends Component { map, matchContentToUrl, query, + receivedPositionResponse, setLocationToCurrent, setMapCenter } = this.props @@ -119,6 +137,21 @@ class ResponsiveWebapp extends Component { } } + navigator.geolocation.watchPosition( + // On success + (position) => { + const shouldUpdate = this.positionShouldUpdate(position) + if (shouldUpdate) { + receivedPositionResponse({ position }) + } + }, + // On error + (error) => { + console.log('error in watchPosition', error) + }, + // Options + { enableHighAccuracy: true } + ) // If the path changes (e.g., via a back button press) check whether the // main content needs to switch between, for example, a viewer and a search. if (!isEqual(location.pathname, prevProps.location.pathname)) { @@ -154,7 +187,6 @@ class ResponsiveWebapp extends Component { map, matchContentToUrl, parseUrlQueryString, - receivedPositionResponse, setNetworkConnectionLost } = this.props // Add on back button press behavior. @@ -180,18 +212,6 @@ class ResponsiveWebapp extends Component { // Test location availability on load getCurrentPosition(intl) // Also, watch for changes in position on mobile - navigator.geolocation.watchPosition( - // On success - (position) => { - receivedPositionResponse({ position }) - }, - // On error - (error) => { - console.log('error in watchPosition', error) - }, - // Options - { enableHighAccuracy: true } - ) } // Handle routing to a specific part of the app (e.g. stop viewer) on page // load. (This happens prior to routing request in case special routerId is @@ -426,10 +446,12 @@ class RouterWrapperWithAuth0 extends Component { } const mapStateToWrapperProps = (state) => { - const { homeTimezone, map, persistence, reactRouter } = state.otp.config + const { homeTimezone, location, map, persistence, reactRouter } = + state.otp.config return { auth0Config: getAuth0Config(persistence), autoFly: map.autoFlyOnTripFormUpdate, + currentPosition: location?.currentPosition, defaultLocale: getDefaultLocale(state.otp.config, state.user.loggedInUser), homeTimezone, locale: state.otp.ui.locale, From 8271f4e967ac5f9aa0f67389a0adb2db97e58f1a Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:18:35 -0600 Subject: [PATCH 4/7] Cleaner nearby view styling on mobile --- lib/components/mobile/navigation-bar.js | 2 +- lib/components/viewers/nearby/nearby-view.tsx | 9 ++++++--- lib/components/viewers/nearby/styled.tsx | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/components/mobile/navigation-bar.js b/lib/components/mobile/navigation-bar.js index 1e7b0079c..a31e75d02 100644 --- a/lib/components/mobile/navigation-bar.js +++ b/lib/components/mobile/navigation-bar.js @@ -64,7 +64,7 @@ class MobileNavigationBar extends Component { const backButtonText = intl.formatMessage({ id: 'common.forms.back' }) return ( -
+
diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index 1405f9eae..cf9b1d75b 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -22,6 +22,7 @@ import { Scrollable } from './styled' import FromToPicker from './from-to-picker' +import InvisibleA11yLabel from '../../util/invisible-a11y-label' import RentalStation from './rental-station' import Stop from './stop' import Vehicle from './vehicle-rent' @@ -246,6 +247,8 @@ function NearbyView({ )) + console.log(nearbyItemList) + useEffect(() => { if (!staleData) { setLoading(false) @@ -273,16 +276,16 @@ function NearbyView({ /> )} {nearby && ( -

+ -

+ )} {/* This is used to scroll to top */}
diff --git a/lib/components/viewers/nearby/styled.tsx b/lib/components/viewers/nearby/styled.tsx index d088ebbfe..8ee6bef6e 100644 --- a/lib/components/viewers/nearby/styled.tsx +++ b/lib/components/viewers/nearby/styled.tsx @@ -18,6 +18,10 @@ export const NearbySidebarContainer = styled.ol` gap: 1em; padding: 0 1em; list-style: none; + + @media (max-width: 768px) { + min-height: calc(100vh - 50px); + } ` export const Card = styled.div` From 50aefa17da6c57be81c3bd0e678edb27369469a6 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:00:57 -0600 Subject: [PATCH 5/7] update snapshots --- .../viewers/__snapshots__/nearby-view.js.snap | 66 ++++++++++++------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap index 65c9368a3..1a5af6b06 100644 --- a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap +++ b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap @@ -57,38 +57,47 @@ exports[`components > viewers > nearby view renders nothing on a blank page 1`] title="components.NearbyView.header" /> -

- - components.NearbyView.nearbyListIntro - -

+ + components.NearbyView.nearbyListIntro + + +
    @@ -4091,38 +4100,47 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` title="components.NearbyView.header" /> -

    - - components.NearbyView.nearbyListIntro - -

    + + components.NearbyView.nearbyListIntro + + +
      From 91d6e492e1711ff3bc6f3a39900ae85a3c8862f9 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:19:17 -0600 Subject: [PATCH 6/7] Only watch position on mobile --- lib/components/app/responsive-webapp.js | 33 ++++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index 2d9c165b6..1e937aaed 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -137,21 +137,24 @@ class ResponsiveWebapp extends Component { } } - navigator.geolocation.watchPosition( - // On success - (position) => { - const shouldUpdate = this.positionShouldUpdate(position) - if (shouldUpdate) { - receivedPositionResponse({ position }) - } - }, - // On error - (error) => { - console.log('error in watchPosition', error) - }, - // Options - { enableHighAccuracy: true } - ) + if (isMobile()) { + navigator.geolocation.watchPosition( + // On success + (position) => { + const shouldUpdate = this.positionShouldUpdate(position) + if (shouldUpdate) { + receivedPositionResponse({ position }) + } + }, + // On error + (error) => { + console.log('error in watchPosition', error) + }, + // Options + { enableHighAccuracy: true } + ) + } + // If the path changes (e.g., via a back button press) check whether the // main content needs to switch between, for example, a viewer and a search. if (!isEqual(location.pathname, prevProps.location.pathname)) { From 87e1ac8a29e14cbdeb31b2655ffdb6aa1841401f Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:29:41 -0600 Subject: [PATCH 7/7] Fix comments and console logs --- lib/components/app/responsive-webapp.js | 3 ++- lib/components/viewers/nearby/nearby-view.tsx | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index 1e937aaed..c2e11360c 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -57,6 +57,7 @@ class ResponsiveWebapp extends Component { // Check if the position has changed enough to update the currentPosition // (prevent constant updates in nearby view) + // .001 works out to be about 94-300 ft depending on the longitude. positionShouldUpdate = (position) => { const { currentPosition } = this.props if (!currentPosition.coords) return true @@ -137,6 +138,7 @@ class ResponsiveWebapp extends Component { } } + // Watch for position changing on mobile if (isMobile()) { navigator.geolocation.watchPosition( // On success @@ -214,7 +216,6 @@ class ResponsiveWebapp extends Component { if (isMobile()) { // Test location availability on load getCurrentPosition(intl) - // Also, watch for changes in position on mobile } // Handle routing to a specific part of the app (e.g. stop viewer) on page // load. (This happens prior to routing request in case special routerId is diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index cf9b1d75b..9c60ff677 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -247,8 +247,6 @@ function NearbyView({ )) - console.log(nearbyItemList) - useEffect(() => { if (!staleData) { setLoading(false)