fix: Always show most recent position for tracked callsigns
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 <noreply@anthropic.com>
This commit is contained in:
parent
9f52f8cb49
commit
90d7f58a53
1 changed files with 17 additions and 1 deletions
|
|
@ -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(%{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue