"""
end
defp connection_indicator(assigns) do
~H"""
<%= case @connection_status do %>
<% "connected" -> %>
Connected to APRS-IS
<% "connecting" -> %>
Connecting to APRS-IS...
<% "disconnected" -> %>
Disconnected from APRS-IS
<% _ -> %>
Initializing...
<% end %>
"""
end
defp view_toggle(assigns) do
~H"""
"""
end
defp callsign_filter(assigns) do
~H"""
<%= if @tracked_callsign_latest_packet do %>
Last seen: {time_ago_in_words(get_received_at(@tracked_callsign_latest_packet))}
<% end %>
"""
end
defp packet_list(assigns) do
~H"""
<.packet_card packet={packet} />
"""
end
defp packet_card(assigns) do
~H"""
{@packet.sender}
<%= if @packet.ssid && @packet.ssid != "0" do %>
-{@packet.ssid}
<% end %>
<%= if @packet.has_position do %>
📍 {format_coordinates(@packet.lat, @packet.lon)}
<% end %>
<%= if @packet.comment do %>
{@packet.comment}
<% end %>
via {@packet.path || "direct"} • {time_ago_in_words(@packet.received_at)}
<%= if @packet.has_position do %>
<% end %>
"""
end
# Helper functions
defp format_coordinates(lat, lon) when is_number(lat) and is_number(lon) do
"#{Float.round(lat, 4)}, #{Float.round(lon, 4)}"
end
defp format_coordinates(_, _), do: "Unknown location"
# Style component for better organization
def map_styles(assigns) do
~H"""
"""
end
# Helper function to get received_at from packet (handles both structs and maps)
defp get_received_at(%Aprsme.Packet{} = packet) do
packet.received_at
end
defp get_received_at(packet) when is_map(packet) do
# For regular maps, try both atom and string keys
Map.get(packet, :received_at) || Map.get(packet, "received_at")
end
defp get_received_at(_), do: nil
end