diff --git a/assets/js/app.js b/assets/js/app.js index 34316da..c673ab7 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -183,6 +183,8 @@ window.addEventListener("phx:page-loading-stop", info => topbar.hide()) window.addEventListener("js:exec", e => e.target[e.detail.call](...e.detail.args)) // connect if there are any LiveViews on the page +liveSocket.getSocket().onOpen(() => execJS("#connection-status", "js-hide")) +liveSocket.getSocket().onError(() => execJS("#connection-status", "js-show")) liveSocket.connect() // expose liveSocket on window for web console debug logs and latency simulation: diff --git a/lib/live_beats_web/live/live_helpers.ex b/lib/live_beats_web/live/live_helpers.ex index c0b0690..109c3ef 100644 --- a/lib/live_beats_web/live/live_helpers.ex +++ b/lib/live_beats_web/live/live_helpers.ex @@ -16,12 +16,37 @@ defmodule LiveBeatsWeb.LiveHelpers do Routes.song_index_path(LiveBeatsWeb.Endpoint, :index, profile.username) end + def connection_status(assigns) do + ~H""" +
+ <%= render_slot(@inner_block) %> +
+