From 7b8b417673574877b4d1302fabd5ede4c04a434a Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 25 Jul 2025 14:26:58 -0500 Subject: [PATCH] Address PR feedback: Add defensive handling and documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add nil handling for @last_update_at in template with fallback message - Add documentation comments explaining timestamp update logic - Improve code clarity based on review feedback Addresses suggestions from automated PR review. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/aprsme_web/live/map_live/index.ex | 16 +++++++++++----- lib/aprsme_web/live/map_live/packet_processor.ex | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index 937f182..369e9a0 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -200,7 +200,8 @@ defmodule AprsmeWeb.MapLive.Index do overlay_callsign: "", # Slideover state - will be set based on screen size slideover_open: true, - # Track when last update occurred for display + # Track when last update occurred for real-time display in map sidebar + # Updated when packets are processed or map bounds change last_update_at: DateTime.utc_now() ) end @@ -1311,10 +1312,14 @@ defmodule AprsmeWeb.MapLive.Index do {gettext("Last Update")}
-
{time_ago_in_words(@last_update_at)}
-
- {Calendar.strftime(@last_update_at, "%Y-%m-%d %H:%M UTC")} -
+ <%= if @last_update_at do %> +
{time_ago_in_words(@last_update_at)}
+
+ {Calendar.strftime(@last_update_at, "%Y-%m-%d %H:%M UTC")} +
+ <% else %> +
No updates yet
+ <% end %>
@@ -1641,6 +1646,7 @@ defmodule AprsmeWeb.MapLive.Index do socket |> assign(map_bounds: map_bounds, packet_state: updated_packet_state) |> assign(needs_initial_historical_load: false) + # Update last update timestamp when map bounds change - this triggers data refresh |> assign(last_update_at: DateTime.utc_now()) # Load historical packets for the new bounds (now socket.assigns.map_bounds is correct) diff --git a/lib/aprsme_web/live/map_live/packet_processor.ex b/lib/aprsme_web/live/map_live/packet_processor.ex index 3c7f407..7fddaf9 100644 --- a/lib/aprsme_web/live/map_live/packet_processor.ex +++ b/lib/aprsme_web/live/map_live/packet_processor.ex @@ -39,7 +39,8 @@ defmodule AprsmeWeb.MapLive.PacketProcessor do # Handle packet visibility logic socket = handle_packet_visibility(packet, lat, lon, callsign_key, socket) - # Update last update timestamp for display purposes + # Update last update timestamp for real-time display in map sidebar + # This timestamp is shown to users to indicate when data was last refreshed socket = assign(socket, :last_update_at, DateTime.utc_now()) {:noreply, socket}