|
|
@@ -13,7 +13,8 @@ defmodule VaccinsWeb.IndexLive do
|
|
|
pending: %{},
|
|
|
availabilities: locations |> Map.new(&{&1.id, []}),
|
|
|
location_cs: LocationStore.LocationRaw.changeset(%{})
|
|
|
- )}
|
|
|
+ )
|
|
|
+ |> trigger_global_refresh}
|
|
|
end
|
|
|
|
|
|
@impl true
|
|
|
@@ -25,11 +26,8 @@ defmodule VaccinsWeb.IndexLive do
|
|
|
end
|
|
|
|
|
|
@impl true
|
|
|
- def handle_event("trigger_all", _, socket = %{assigns: %{locations: locations}}) do
|
|
|
- locations
|
|
|
- |> Enum.each(&send_update(VaccinsWeb.LocationComponent, id: &1.id, force_refresh: true))
|
|
|
-
|
|
|
- {:noreply, socket}
|
|
|
+ def handle_event("trigger_all", _, socket) do
|
|
|
+ {:noreply, socket |> trigger_global_refresh}
|
|
|
end
|
|
|
|
|
|
@impl true
|
|
|
@@ -46,4 +44,11 @@ defmodule VaccinsWeb.IndexLive do
|
|
|
send_update(VaccinsWeb.LocationComponent, id: id, availabilities: res)
|
|
|
{:noreply, socket |> assign(pending: pending |> Map.delete(ref))}
|
|
|
end
|
|
|
+
|
|
|
+ defp trigger_global_refresh(socket = %{assigns: %{locations: locations}}) do
|
|
|
+ locations
|
|
|
+ |> Enum.each(&send_update(VaccinsWeb.LocationComponent, id: &1.id, force_refresh: true))
|
|
|
+
|
|
|
+ socket
|
|
|
+ end
|
|
|
end
|