Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Have the map show the selected itinerary, rather than a random member of the group #2314

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

joshlarson
Copy link
Contributor

Before

Screenshot 2025-01-08 at 3 16 23 PM (Note that the selected itinerary uses the Orange Line, but the line on the map is the Green Line color)

After

Screenshot 2025-01-08 at 3 16 40 PM

No Ticket.

@joshlarson joshlarson requested a review from a team as a code owner January 8, 2025 20:20
@joshlarson joshlarson enabled auto-merge (squash) January 8, 2025 20:20
@@ -204,9 +204,25 @@ defmodule DotcomWeb.Live.TripPlanner do
def handle_event("select_itinerary", %{"index" => index}, socket) do
index = String.to_integer(index)

new_map = %{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a fundamental issue here, which is that lines and points have to be re-computed at various different points, and forgetting to do that somewhere introduces bugs like this one. (It also creates a bunch of duplicative code for re-calculating lines and points any time they ought to change)

I think the Right™ solution is to calculate lines and points (and a few other things, like pins) at the top of render, based on the result set and user interactions, and not try to have this one-to-one mapping between components-on-screen and top-level state fields.

I'd rather actually tackle that refactor as a follow-up, since fixing this bug in this way was pretty easy, and because trying to refactor the state right now risks conflicting with other ongoing trip planner work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ Thanks for this! I agree with your take on what an improvement on this would be.

Copy link
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

@joshlarson joshlarson merged commit fdfa163 into main Jan 9, 2025
20 checks passed
@joshlarson joshlarson deleted the jdl/fix-map-display-for-different-itineraries branch January 9, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants