From fd1708e7910e863a4bdac74b90d7ef334c10f3e1 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 16 Jun 2025 11:41:57 -0500 Subject: [PATCH] callsign page fixes --- .../components/layouts/root.html.heex | 2 +- lib/aprs_web/live/map_live/callsign_view.ex | 84 +++++++------------ .../live/map_live/callsign_view_test.exs | 34 +++++--- 3 files changed, 55 insertions(+), 65 deletions(-) diff --git a/lib/aprs_web/components/layouts/root.html.heex b/lib/aprs_web/components/layouts/root.html.heex index 28a36c1..9a69a2a 100644 --- a/lib/aprs_web/components/layouts/root.html.heex +++ b/lib/aprs_web/components/layouts/root.html.heex @@ -4,7 +4,7 @@ - <.live_title suffix=" · Phoenix Framework"> + <.live_title suffix=" · aprs.me"> {assigns[:page_title] || "Aprs"} diff --git a/lib/aprs_web/live/map_live/callsign_view.ex b/lib/aprs_web/live/map_live/callsign_view.ex index aacd22b..e73f12b 100644 --- a/lib/aprs_web/live/map_live/callsign_view.ex +++ b/lib/aprs_web/live/map_live/callsign_view.ex @@ -64,8 +64,8 @@ defmodule AprsWeb.MapLive.CallsignView do # Schedule regular cleanup of old packets from the map Process.send_after(self(), :cleanup_old_packets, 60_000) - # Schedule initialization of replay after a short delay - Process.send_after(self(), :initialize_replay, 2000) + # Auto-start replay after a short delay + Process.send_after(self(), :auto_start_replay, 2000) {:ok, socket} else @@ -109,33 +109,6 @@ defmodule AprsWeb.MapLive.CallsignView do {:noreply, socket} end - def handle_event("toggle_replay", _params, socket) do - if socket.assigns.replay_active do - # Stop replay - if socket.assigns.replay_timer_ref do - Process.cancel_timer(socket.assigns.replay_timer_ref) - end - - # Clear historical packets from map - socket = push_event(socket, "clear_historical_packets", %{}) - - socket = - assign(socket, - replay_active: false, - replay_paused: false, - replay_timer_ref: nil, - replay_index: 0, - historical_packets: %{} - ) - - {:noreply, socket} - else - # Start replay - socket = start_historical_replay(socket) - {:noreply, assign(socket, replay_active: true, replay_paused: false)} - end - end - def handle_event("pause_replay", _params, socket) do if socket.assigns.replay_timer_ref do Process.cancel_timer(socket.assigns.replay_timer_ref) @@ -166,6 +139,15 @@ defmodule AprsWeb.MapLive.CallsignView do def handle_event("map_ready", _params, socket) do socket = assign(socket, map_ready: true) + # Auto-start replay if it hasn't been started yet + socket = + if socket.assigns.replay_started do + socket + else + socket = start_historical_replay(socket) + assign(socket, replay_started: true, replay_active: true) + end + # If we have a pending geolocation, zoom to it now socket = if socket.assigns.pending_geolocation do @@ -214,12 +196,17 @@ defmodule AprsWeb.MapLive.CallsignView do socket = push_event(socket, "zoom_to_location", %{lat: lat, lng: lng, zoom: 12}) {:noreply, socket} - :initialize_replay -> - # Only start replay if it hasn't been started yet + :auto_start_replay -> + # Auto-start replay if it hasn't been started yet and map is ready if not socket.assigns.replay_started and socket.assigns.map_ready do socket = start_historical_replay(socket) - {:noreply, assign(socket, replay_started: true)} + {:noreply, assign(socket, replay_started: true, replay_active: true)} else + # If map isn't ready yet, try again in a bit + if not socket.assigns.map_ready do + Process.send_after(self(), :auto_start_replay, 1000) + end + {:noreply, socket} end @@ -583,15 +570,8 @@ defmodule AprsWeb.MapLive.CallsignView do -
- - - <%= if @replay_active do %> + <%= if @replay_active do %> +
@@ -608,8 +588,8 @@ defmodule AprsWeb.MapLive.CallsignView do name="speed" />x
- <% end %> -
+ + <% end %>