Skip to content

Commit

Permalink
fix: Missed Stops should not display until detour finished (#2520)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahpurcell authored Mar 26, 2024
1 parent 2ccecdd commit fb83a22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions assets/src/hooks/useDetour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ export const useDetour = ({ routePatternId, shape }: OriginalRoute) => {
setState(DetourState.Edit)
}

const missedStops = finishedDetour?.missedStops || []
const missedStops = finishedDetour?.missedStops || undefined

const missedStopIds = new Set(missedStops.map((stop) => stop.id))
const missedStopIds = missedStops
? new Set(missedStops.map((stop) => stop.id))
: new Set()
const stops = (shape.stops || []).map((stop) => ({
...stop,
missed: missedStopIds.has(stop.id),
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/hooks/useDetour.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ describe("useDetour", () => {
act(() => result.current.undo?.())

await waitFor(() => {
expect(result.current.missedStops).toHaveLength(0)
expect(result.current.missedStops).toBeUndefined()
})
})

Expand Down

0 comments on commit fb83a22

Please sign in to comment.