From 5d93587e0b342dab2847abc51f08275ec7dad76e Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:08:12 -0600 Subject: [PATCH 1/9] move watchPosition back to componentDidMount --- lib/components/app/responsive-webapp.js | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/components/app/responsive-webapp.js b/lib/components/app/responsive-webapp.js index c2e11360c..7c7480921 100644 --- a/lib/components/app/responsive-webapp.js +++ b/lib/components/app/responsive-webapp.js @@ -87,7 +87,6 @@ class ResponsiveWebapp extends Component { map, matchContentToUrl, query, - receivedPositionResponse, setLocationToCurrent, setMapCenter } = this.props @@ -138,25 +137,6 @@ class ResponsiveWebapp extends Component { } } - // Watch for position changing on mobile - 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)) { @@ -192,6 +172,7 @@ class ResponsiveWebapp extends Component { map, matchContentToUrl, parseUrlQueryString, + receivedPositionResponse, setNetworkConnectionLost } = this.props // Add on back button press behavior. @@ -216,6 +197,21 @@ class ResponsiveWebapp extends Component { if (isMobile()) { // Test location availability on load getCurrentPosition(intl) + // Watch for position changing on mobile + navigator.geolocation.watchPosition( + // On success + (position) => { + if (this.positionShouldUpdate(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 From f6d2d866f9675b354ab69d289a2365b63dcfcdbe Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:09:11 -0600 Subject: [PATCH 2/9] Simplify scroll, and setLoading when there's stale data --- lib/components/viewers/nearby/nearby-view.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index 9c60ff677..d8bb33049 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import { FormattedMessage, useIntl } from 'react-intl' import { Location } from '@opentripplanner/types' import { MapRef, useMap } from 'react-map-gl' -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import React, { useCallback, useEffect, useMemo, useState } from 'react' import * as apiActions from '../../../actions/api' import * as mapActions from '../../../actions/map' @@ -128,7 +128,6 @@ function NearbyView({ const map = useMap().default const intl = useIntl() const [loading, setLoading] = useState(true) - const firstItemRef = useRef(null) const finalNearbyCoords = useMemo( () => getNearbyCoordsFromUrlOrLocationOrMapCenter( @@ -180,9 +179,11 @@ function NearbyView({ }, [map, setViewedNearbyCoords, setHighlightedLocation]) useEffect(() => { - if (typeof firstItemRef.current?.scrollIntoView === 'function') { - firstItemRef.current?.scrollIntoView({ behavior: 'smooth' }) - } + window.scrollTo({ + behavior: 'smooth', + left: 0, + top: 0 + }) if (finalNearbyCoords) { fetchNearby(finalNearbyCoords, radius, currentServiceWeek) setLoading(true) @@ -250,6 +251,11 @@ function NearbyView({ useEffect(() => { if (!staleData) { setLoading(false) + } else if (staleData) { + // If there's stale data, fetch again + setLoading(true) + finalNearbyCoords && + fetchNearby(finalNearbyCoords, radius, currentServiceWeek) } }, [nearby, staleData]) @@ -285,8 +291,6 @@ function NearbyView({ className="base-color-bg" style={{ marginBottom: 0 }} > - {/* This is used to scroll to top */} -
{loading && ( From 5f8450e82b55913de0669360b758695dbbe7065a Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:09:32 -0600 Subject: [PATCH 3/9] Add a margin-bottom to nearby view --- lib/components/viewers/nearby/styled.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/components/viewers/nearby/styled.tsx b/lib/components/viewers/nearby/styled.tsx index 8ee6bef6e..ad26d4ebd 100644 --- a/lib/components/viewers/nearby/styled.tsx +++ b/lib/components/viewers/nearby/styled.tsx @@ -19,6 +19,10 @@ export const NearbySidebarContainer = styled.ol` padding: 0 1em; list-style: none; + & > li:last-of-type { + margin-bottom: 2em; + } + @media (max-width: 768px) { min-height: calc(100vh - 50px); } From 2ea61241d242abfbf0caca1e0775e739762c4acb Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:15:22 -0600 Subject: [PATCH 4/9] fix styling --- lib/components/viewers/nearby/styled.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/components/viewers/nearby/styled.tsx b/lib/components/viewers/nearby/styled.tsx index ad26d4ebd..48acffebb 100644 --- a/lib/components/viewers/nearby/styled.tsx +++ b/lib/components/viewers/nearby/styled.tsx @@ -20,7 +20,11 @@ export const NearbySidebarContainer = styled.ol` list-style: none; & > li:last-of-type { - margin-bottom: 2em; + margin-bottom: 1em; + } + + & > li:first-of-type { + margin-top: 1em; } @media (max-width: 768px) { From 24502beeaf6d388888deb47785f02567d59f67a1 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:15:48 -0600 Subject: [PATCH 5/9] Filter out empty stops entirely instead of rendering empty list items --- lib/components/viewers/nearby/nearby-view.tsx | 67 +++++++++++++---- lib/components/viewers/nearby/stop.tsx | 75 ++++++++++--------- 2 files changed, 94 insertions(+), 48 deletions(-) diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index d8bb33049..76e849309 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -9,11 +9,27 @@ import * as mapActions from '../../../actions/map' import * as uiActions from '../../../actions/ui' import { AppReduxState } from '../../../util/state-types' import { getCurrentServiceWeek } from '../../../util/current-service-week' -import { SetLocationHandler, ZoomToPlaceHandler } from '../../util/types' +import { + PatternStopTime, + SetLocationHandler, + ZoomToPlaceHandler +} from '../../util/types' +import coreUtils from '@opentripplanner/core-utils' + +import { NearbyViewConfig } from '../../../util/config-types' + +import FromToPicker from './from-to-picker' +import InvisibleA11yLabel from '../../util/invisible-a11y-label' import Loading from '../../narrative/loading' import MobileContainer from '../../mobile/container' import MobileNavigationBar from '../../mobile/navigation-bar' import PageTitle from '../../util/page-title' + +import RentalStation from './rental-station' +import Stop, { fullTimestamp, patternArrayforStops } from './stop' +import Vehicle from './vehicle-rent' +import VehicleParking from './vehicle-parking' + import VehiclePositionRetriever from '../vehicle-position-retriever' import { @@ -21,14 +37,8 @@ import { NearbySidebarContainer, 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' -import VehicleParking from './vehicle-parking' -const AUTO_REFRESH_INTERVAL = 15000 +const AUTO_REFRESH_INTERVAL = 15000000 // TODO: use lonlat package type LatLonObj = { lat: number; lon: number } @@ -50,8 +60,10 @@ type Props = { location: string mobile?: boolean nearby: any + nearbyViewConfig?: NearbyViewConfig nearbyViewCoords?: LatLonObj radius?: number + routeSortComparator: (a: PatternStopTime, b: PatternStopTime) => number setHighlightedLocation: (location: Location | null) => void setLocation: SetLocationHandler setMainPanelContent: (content: number) => void @@ -118,8 +130,10 @@ function NearbyView({ location, mobile, nearby, + nearbyViewConfig, nearbyViewCoords, radius, + routeSortComparator, setHighlightedLocation, setMainPanelContent, setViewedNearbyCoords, @@ -224,9 +238,19 @@ function NearbyView({ .flat(Infinity) ) ) + + // If configured, filter out stops that don't have any patterns + const filteredNearby = nearby?.filter((n: any) => { + if (n.place.__typename === 'Stop' && nearbyViewConfig?.hideEmptyStops) { + const patternArray = patternArrayforStops(n.place, routeSortComparator) + if (patternArray?.length === 0) return false + } + return true + }) + const nearbyItemList = - nearby?.map && - nearby?.map((n: any) => ( + filteredNearby?.map && + filteredNearby?.map((n: any) => (
  • 0 ? ( + ) : filteredNearby?.length > 0 ? ( nearbyItemList ) : ( @@ -313,7 +337,8 @@ function NearbyView({ const mapStateToProps = (state: AppReduxState) => { const { config, location, transitIndex, ui } = state.otp - const { map, routeViewer } = config + const { map, nearbyView: nearbyViewConfig, routeViewer } = config + const transitOperators = config?.transitOperators || [] const { nearbyViewCoords } = ui const { nearby } = transitIndex const { entityId } = state.router.location.query @@ -326,6 +351,20 @@ const mapStateToProps = (state: AppReduxState) => { ? getCurrentServiceWeek() : undefined + // TODO: Refine so we don't have this same thing in stops.tsx + // Default sort: departure time + let routeSortComparator = (a: PatternStopTime, b: PatternStopTime) => + fullTimestamp(a.stoptimes?.[0]) - fullTimestamp(b.stoptimes?.[0]) + + if (nearbyViewConfig?.useRouteViewSort) { + routeSortComparator = (a: PatternStopTime, b: PatternStopTime) => + coreUtils.route.makeRouteComparator(transitOperators)( + // @ts-expect-error core-utils types are wrong! + a.pattern.route, + b.pattern.route + ) + } + return { currentPosition, currentServiceWeek, @@ -335,8 +374,10 @@ const mapStateToProps = (state: AppReduxState) => { homeTimezone: config.homeTimezone, location: state.router.location.hash, nearby: nearby?.data, + nearbyViewConfig, nearbyViewCoords, - radius: config.nearbyView?.radius + radius: config.nearbyView?.radius, + routeSortComparator } } diff --git a/lib/components/viewers/nearby/stop.tsx b/lib/components/viewers/nearby/stop.tsx index c98d288c1..973f8ddb3 100644 --- a/lib/components/viewers/nearby/stop.tsx +++ b/lib/components/viewers/nearby/stop.tsx @@ -16,7 +16,7 @@ import StopCardHeader from './stop-card-header' const { getUserTimezone } = coreUtils.time -const fullTimestamp = (stoptime: StopTime) => +export const fullTimestamp = (stoptime: StopTime) => (stoptime.serviceDay || 0) + (stoptime.realtimeDeparture || 0) type Props = { @@ -27,14 +27,11 @@ type Props = { stopData: StopData & { nearbyRoutes?: string[] } } -const Stop = ({ - fromToSlot, - homeTimezone, - nearbyViewConfig, - routeSortComparator, - stopData -}: Props): JSX.Element => { - const patternRows = (stopData.stoptimesForPatterns || []) +export const patternArrayforStops = ( + stopData: StopData & { nearbyRoutes?: string[] }, + routeSortComparator: (a: PatternStopTime, b: PatternStopTime) => number +): Array | undefined => { + return stopData?.stoptimesForPatterns ?.reduce((acc, cur) => { const currentHeadsign = extractHeadsignFromPattern(cur.pattern) const dupe = acc.findIndex((p) => { @@ -65,30 +62,40 @@ const Stop = ({ return acc }, []) .sort(routeSortComparator) - .map((st: any, index: number) => { - const sortedStopTimes = st.stoptimes.sort( - (a: StopTime, b: StopTime) => fullTimestamp(a) - fullTimestamp(b) - ) - if ( - // NearbyRoutes if present is populated with a list of routes that appear - // in the current service period. - stopData.nearbyRoutes && - !stopData.nearbyRoutes.includes(st?.pattern?.route?.gtfsId) - ) { - return <> - } - return ( - - ) - }) +} + +const Stop = ({ + fromToSlot, + homeTimezone, + nearbyViewConfig, + routeSortComparator, + stopData +}: Props): JSX.Element => { + const patternArray = patternArrayforStops(stopData, routeSortComparator) + const patternRows = patternArray?.map((st: any, index: number) => { + const sortedStopTimes = st.stoptimes.sort( + (a: StopTime, b: StopTime) => fullTimestamp(a) - fullTimestamp(b) + ) + if ( + // NearbyRoutes if present is populated with a list of routes that appear + // in the current service period. + stopData.nearbyRoutes && + !stopData.nearbyRoutes.includes(st?.pattern?.route?.gtfsId) + ) { + return <> + } + return ( + + ) + }) const inHomeTimezone = homeTimezone && homeTimezone === getUserTimezone() const timezoneWarning = !inHomeTimezone && ( @@ -96,8 +103,6 @@ const Stop = ({ ) - if (nearbyViewConfig?.hideEmptyStops && patternRows.length === 0) return <> - return ( Date: Wed, 18 Dec 2024 15:24:30 -0600 Subject: [PATCH 6/9] update snapshots --- .../viewers/__snapshots__/nearby-view.js.snap | 354 +++++++++--------- 1 file changed, 175 insertions(+), 179 deletions(-) diff --git a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap index 1a5af6b06..629be1f50 100644 --- a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap +++ b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap @@ -35,6 +35,7 @@ exports[`components > viewers > nearby view renders nothing on a blank page 1`] fetchNearby={[Function]} homeTimezone="America/Los_Angeles" nearby={Array []} + routeSortComparator={[Function]} setHighlightedLocation={[Function]} setLocation={[Function]} setMainPanelContent={[Function]} @@ -66,7 +67,7 @@ exports[`components > viewers > nearby view renders nothing on a blank page 1`] } >

    viewers > nearby view renders nothing on a blank page 1`] } >
      -
      @@ -4078,6 +4076,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` }, ] } + routeSortComparator={[Function]} setHighlightedLocation={[Function]} setLocation={[Function]} setMainPanelContent={[Function]} @@ -4109,7 +4108,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` } >

      viewers > nearby view renders proper scooter dates 1`] = ` } >
        -
      1. viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.realtime" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` title="components.StopTimeCell.scheduled" > viewers > nearby view renders proper scooter dates 1`] = ` > Date: Thu, 19 Dec 2024 10:16:34 -0600 Subject: [PATCH 7/9] Fix import warnings --- lib/components/viewers/nearby/nearby-view.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index 76e849309..0b0b306ac 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -2,6 +2,7 @@ import { connect } from 'react-redux' import { FormattedMessage, useIntl } from 'react-intl' import { Location } from '@opentripplanner/types' import { MapRef, useMap } from 'react-map-gl' +import coreUtils from '@opentripplanner/core-utils' import React, { useCallback, useEffect, useMemo, useState } from 'react' import * as apiActions from '../../../actions/api' @@ -9,27 +10,17 @@ import * as mapActions from '../../../actions/map' import * as uiActions from '../../../actions/ui' import { AppReduxState } from '../../../util/state-types' import { getCurrentServiceWeek } from '../../../util/current-service-week' +import { NearbyViewConfig } from '../../../util/config-types' import { PatternStopTime, SetLocationHandler, ZoomToPlaceHandler } from '../../util/types' -import coreUtils from '@opentripplanner/core-utils' - -import { NearbyViewConfig } from '../../../util/config-types' - -import FromToPicker from './from-to-picker' import InvisibleA11yLabel from '../../util/invisible-a11y-label' import Loading from '../../narrative/loading' import MobileContainer from '../../mobile/container' import MobileNavigationBar from '../../mobile/navigation-bar' import PageTitle from '../../util/page-title' - -import RentalStation from './rental-station' -import Stop, { fullTimestamp, patternArrayforStops } from './stop' -import Vehicle from './vehicle-rent' -import VehicleParking from './vehicle-parking' - import VehiclePositionRetriever from '../vehicle-position-retriever' import { @@ -37,6 +28,11 @@ import { NearbySidebarContainer, Scrollable } from './styled' +import FromToPicker from './from-to-picker' +import RentalStation from './rental-station' +import Stop, { fullTimestamp, patternArrayforStops } from './stop' +import Vehicle from './vehicle-rent' +import VehicleParking from './vehicle-parking' const AUTO_REFRESH_INTERVAL = 15000000 From c076733288a9b1c761b577f0bab96dba6f1bd2e5 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:24:25 -0600 Subject: [PATCH 8/9] Add todo for typing of nearby --- lib/components/viewers/nearby/nearby-view.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index 0b0b306ac..bcf77e05f 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -55,6 +55,7 @@ type Props = { hideBackButton?: boolean location: string mobile?: boolean + // Todo: type nearby results nearby: any nearbyViewConfig?: NearbyViewConfig nearbyViewCoords?: LatLonObj From 5729b217e653a42674b4ea7d2e038285f3e39ff1 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:32:06 -0600 Subject: [PATCH 9/9] clean up nearby filtering --- lib/components/viewers/nearby/nearby-view.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/viewers/nearby/nearby-view.tsx b/lib/components/viewers/nearby/nearby-view.tsx index bcf77e05f..be54085ae 100644 --- a/lib/components/viewers/nearby/nearby-view.tsx +++ b/lib/components/viewers/nearby/nearby-view.tsx @@ -240,7 +240,7 @@ function NearbyView({ const filteredNearby = nearby?.filter((n: any) => { if (n.place.__typename === 'Stop' && nearbyViewConfig?.hideEmptyStops) { const patternArray = patternArrayforStops(n.place, routeSortComparator) - if (patternArray?.length === 0) return false + return !(patternArray?.length === 0) } return true })