From 24382f5993d510a23b2e3013c60eecd3ef7be001 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 30 Jul 2025 13:04:36 -0500 Subject: [PATCH] fix: Preserve station-specific URLs when updating map state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix URL persistence for station routes (e.g., /w5isp) - Update handle_url_update to maintain callsign in path - Modify tracking events to use consistent URL structure - Prevent unwanted redirects from /callsign to / URLs now correctly persist as /w5isp?lat=...&lng=...&z=... instead of redirecting to root with query parameters. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/aprsme_web/live/map_live/index.ex | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index c3a35b5..ddfb8c0 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -403,12 +403,12 @@ defmodule AprsmeWeb.MapLive.Index do # Clear tracking socket |> assign(tracked_callsign: "") - |> push_patch(to: "/") + |> update_url_with_current_state() else - # Set tracking + # Set tracking and navigate to callsign URL socket |> assign(tracked_callsign: normalized_callsign) - |> push_patch(to: "/?call=#{normalized_callsign}") + |> push_patch(to: "/#{normalized_callsign}") end {:noreply, socket} @@ -419,7 +419,7 @@ defmodule AprsmeWeb.MapLive.Index do socket = socket |> assign(tracked_callsign: "", overlay_callsign: "") - |> push_patch(to: "/") + |> update_url_with_current_state() {:noreply, socket} end @@ -605,7 +605,15 @@ defmodule AprsmeWeb.MapLive.Index do do: "&hist=#{socket.assigns[:historical_hours]}", else: "" - new_path = "/?lat=#{lat}&lng=#{lng}&z=#{zoom}#{trail_param}#{hist_param}" + # Preserve callsign in path if tracking + base_path = + if socket.assigns.tracked_callsign == "" do + "/" + else + "/#{socket.assigns.tracked_callsign}" + end + + new_path = "#{base_path}?lat=#{lat}&lng=#{lng}&z=#{zoom}#{trail_param}#{hist_param}" Logger.debug("Updating URL to: #{new_path}") push_patch(socket, to: new_path, replace: true) end