From 90d7f58a5317e24c835fbf10265543c1e927a61b Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 30 Jul 2025 14:52:53 -0500 Subject: [PATCH] fix: Always show most recent position for tracked callsigns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that when viewing a specific callsign (e.g., /w5isp), the most recent position packet is always displayed, regardless of how old it is or what historical time period is selected. The fix ensures that during historical loading, if we're tracking a specific callsign and it's the first batch, we always include the callsign's most recent packet even if it falls outside the selected historical time filter (1h, 3h, 6h, etc.). This resolves the issue where callsigns with very old last positions would not be visible when viewing their specific page. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../live/map_live/historical_loader.ex | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/aprsme_web/live/map_live/historical_loader.ex b/lib/aprsme_web/live/map_live/historical_loader.ex index 048fbc9..4f26294 100644 --- a/lib/aprsme_web/live/map_live/historical_loader.ex +++ b/lib/aprsme_web/live/map_live/historical_loader.ex @@ -171,7 +171,23 @@ defmodule AprsmeWeb.MapLive.HistoricalLoader do historical_hours = SharedPacketUtils.parse_historical_hours(socket.assigns.historical_hours || "1") params = Map.put(params, :hours_back, historical_hours) - Packets.get_recent_packets(params) + # Get recent packets within time filter + recent_packets = Packets.get_recent_packets(params) + + # If tracking a callsign and this is the first batch, ensure we always include + # the most recent packet for that callsign, even if it's older than the time filter + if socket.assigns.tracked_callsign != "" and batch_offset == 0 do + latest_packet = Packets.get_latest_packet_for_callsign(socket.assigns.tracked_callsign) + + if latest_packet && not Enum.any?(recent_packets, &(&1.id == latest_packet.id)) do + # Add the latest packet to the beginning of the list so it's prioritized + [latest_packet | recent_packets] + else + recent_packets + end + else + recent_packets + end else # Fallback for testing packets_module.get_recent_packets(%{