pause extra map popups when user clicks on one

This commit is contained in:
Graham McIntire 2025-07-08 10:18:07 -05:00
parent 711d92ebb6
commit bcaef2d118
No known key found for this signature in database
2 changed files with 30 additions and 4 deletions

View file

@ -560,13 +560,15 @@ let MapAPRSMap = {
}
// Add the new marker as the most recent for this callsign
// Check if openPopup is explicitly set to false to prevent interrupting user
const shouldOpenPopup = data.openPopup !== false;
self.addMarker({
...data,
historical: false,
is_most_recent_for_callsign: true,
callsign_group: data.callsign_group || data.callsign || incomingCallsign,
popup: data.popup || self.buildPopupContent(data),
openPopup: true,
openPopup: shouldOpenPopup,
});
});
@ -807,6 +809,11 @@ let MapAPRSMap = {
// Add popup if content provided
if (data.popup) {
marker.bindPopup(data.popup, { autoPan: false });
// Handle popup close events for all popups
marker.on("popupclose", () => {
self.pushEvent("popup_closed", {});
});
}
// Handle marker click
@ -820,6 +827,11 @@ let MapAPRSMap = {
});
});
// Handle popup close events
marker.on("popupclose", () => {
self.pushEvent("popup_closed", {});
});
// Mark historical markers for identification
if (data.historical) {
(marker as any)._isHistorical = true;

View file

@ -33,7 +33,7 @@ defmodule AprsmeWeb.MapLive.Index do
socket = assign_defaults(socket, one_hour_ago)
socket = assign(socket, packet_buffer: [], buffer_timer: nil)
socket = assign(socket, all_packets: %{})
socket = assign(socket, all_packets: %{}, station_popup_open: false)
if connected?(socket) do
Endpoint.subscribe("aprs_messages")
@ -66,6 +66,7 @@ defmodule AprsmeWeb.MapLive.Index do
packets: [],
page_title: "APRS Map",
visible_packets: %{},
station_popup_open: false,
map_bounds: %{
north: 49.0,
south: 24.0,
@ -184,7 +185,8 @@ defmodule AprsmeWeb.MapLive.Index do
@impl true
def handle_event("marker_clicked", _params, socket) do
{:noreply, socket}
# When a marker is clicked, mark that a station popup is open
{:noreply, assign(socket, station_popup_open: true)}
end
@impl true
@ -252,6 +254,12 @@ defmodule AprsmeWeb.MapLive.Index do
{:noreply, socket}
end
@impl true
def handle_event("popup_closed", _params, socket) do
# When any popup is closed, mark that no station popup is open
{:noreply, assign(socket, station_popup_open: false)}
end
@impl true
def handle_event("get_assigns", _params, socket) do
send(self(), {:test_assigns, socket.assigns})
@ -405,7 +413,13 @@ defmodule AprsmeWeb.MapLive.Index do
socket =
if marker_data do
push_event(socket, "new_packet", marker_data)
# Only show new packet popup if no station popup is currently open
if socket.assigns.station_popup_open do
# Send without opening popup to avoid interrupting user
push_event(socket, "new_packet", Map.put(marker_data, :openPopup, false))
else
push_event(socket, "new_packet", marker_data)
end
else
socket
end