Skip to content

Commit

Permalink
clean up miles's bad code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-heppner-ibigroup committed Nov 4, 2024
1 parent 71e84f2 commit 6909653
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/components/map/itinerary-summary-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -147,17 +147,14 @@ const ItinerarySummaryOverlay = ({
// @ts-expect-error React context is populated dynamically
const { LegIcon } = useContext(ComponentContext)

const [sharedTimeout, setSharedTimeout] = useState<null | NodeJS.Timeout>(
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<ItinUniquePoint[]>(
(prev: ItinUniquePoint[], curItin: ItinWithGeometry) => {
prev.push(getUniquePoint(curItin, prev))
return prev
Expand All @@ -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)
Expand Down

0 comments on commit 6909653

Please sign in to comment.