From 31d4719bcfd7de9e47a299cd2fc8bed254da2932 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 16 Jun 2025 16:01:12 -0500 Subject: [PATCH] fix historical call load --- lib/aprs_web/live/map_live/callsign_view.ex | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/aprs_web/live/map_live/callsign_view.ex b/lib/aprs_web/live/map_live/callsign_view.ex index f183643..0d737ce 100644 --- a/lib/aprs_web/live/map_live/callsign_view.ex +++ b/lib/aprs_web/live/map_live/callsign_view.ex @@ -55,14 +55,16 @@ defmodule AprsWeb.MapLive.CallsignView do # Pending geolocation to zoom to after map is ready pending_geolocation: nil, # Last known position for auto-zoom - last_known_position: nil + last_known_position: nil, + # Flag to track if packets have been loaded + packets_loaded: false ) if connected?(socket) do Endpoint.subscribe("aprs_messages") - # Load recent packets for this callsign - socket = load_callsign_packets(socket, normalized_callsign) + # Don't load packets here - wait for map_ready event + # socket = load_callsign_packets(socket, normalized_callsign) # Schedule regular cleanup of old packets from the map Process.send_after(self(), :cleanup_old_packets, 60_000) @@ -141,6 +143,16 @@ defmodule AprsWeb.MapLive.CallsignView do def handle_event("map_ready", _params, socket) do socket = assign(socket, map_ready: true) + # Load callsign packets now that the map is ready + socket = + if socket.assigns.packets_loaded do + socket + else + socket + |> load_callsign_packets(socket.assigns.callsign) + |> assign(packets_loaded: true) + end + # Auto-start replay if it hasn't been started yet socket = if socket.assigns.replay_started do