From 6909653a2f2cc6b4f155bc638209cb68b75c382b Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Mon, 4 Nov 2024 12:57:11 -0800 Subject: [PATCH] clean up miles's bad code --- lib/components/map/itinerary-summary-overlay.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/components/map/itinerary-summary-overlay.tsx b/lib/components/map/itinerary-summary-overlay.tsx index d66e50d45..5f47f527d 100644 --- a/lib/components/map/itinerary-summary-overlay.tsx +++ b/lib/components/map/itinerary-summary-overlay.tsx @@ -5,7 +5,7 @@ import { Marker } from 'react-map-gl' import centroid from '@turf/centroid' import distance from '@turf/distance' import polyline from '@mapbox/polyline' -import React, { useContext, useState } from 'react' +import React, { useContext } from 'react' import styled from 'styled-components' import * as narriativeActions from '../../actions/narrative' @@ -147,17 +147,14 @@ const ItinerarySummaryOverlay = ({ // @ts-expect-error React context is populated dynamically const { LegIcon } = useContext(ComponentContext) - const [sharedTimeout, setSharedTimeout] = useState( - null - ) - if (!itins || !visible) return <> const indexedItins: ItinWithGeometry[] = addTrueIndex( itins.map(addItinLineString) ) - const mergedItins = doMergeItineraries(indexedItins).mergedItineraries + const mergedItins: ItinWithGeometry[] = + doMergeItineraries(indexedItins).mergedItineraries - const midPoints = mergedItins.reduce( + const midPoints = mergedItins.reduce( (prev: ItinUniquePoint[], curItin: ItinWithGeometry) => { prev.push(getUniquePoint(curItin, prev)) return prev @@ -173,10 +170,7 @@ const ItinerarySummaryOverlay = ({ return ( <> {midPoints.map( - (mp: { - itin: Itinerary & { index: number } - uniquePoint: [number, number] - }) => + (mp) => // If no itinerary is hovered, show all of them. If one is selected, show only that one // TODO: clean up conditionals, move these to a more appropriate place without breaking indexing (isDefined(visibleItinerary)