diff --git a/assets/js/app.ts b/assets/js/app.ts index 208108c..a719e56 100644 --- a/assets/js/app.ts +++ b/assets/js/app.ts @@ -187,7 +187,7 @@ window }); const liveSocket = new LiveSocket("/live", Socket, { - longPollFallbackMs: 2500, + longPollFallbackMs: 5000, params: { _csrf_token: csrfToken, viewport_width: window.innerWidth }, hooks: Hooks, timeout: 60000, @@ -215,6 +215,17 @@ window.addEventListener("phx:reconnect", ((e: CustomEvent<{ delay?: number }>) = // connect if there are any LiveViews on the page liveSocket.connect(); +// Handle visibility change to ensure reconnection when page becomes visible +// This helps with iOS Safari background/foreground transitions +document.addEventListener("visibilitychange", () => { + if (document.visibilityState === "visible") { + const socket = (liveSocket as any).socket; + if (socket && socket.connectionState() !== "open") { + socket.disconnect(() => socket.connect()); + } + } +}); + // Workaround for Phoenix LiveView bug where fallback timer isn't cleared // after successful WebSocket connection window.addEventListener("phx:live_socket:connect", (_info) => { diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index 2a27019..a40e8b9 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -1433,8 +1433,7 @@ defmodule AprsmeWeb.MapLive.Index do <%= if @slideover_open do %> -
-
+
<% end %>