|
|
@@ -19,10 +19,17 @@ defmodule VaccinsWeb.IndexLive do
|
|
|
location_cs: LocationStore.LocationRaw.changeset(%{}),
|
|
|
display_cs: false
|
|
|
)
|
|
|
+ |> set_title()
|
|
|
|> trigger_global_refresh
|
|
|
|> trigger_periodic_refresh}
|
|
|
end
|
|
|
|
|
|
+ defp set_title(socket = %{assigns: %{locations_with_early_slots: early}}) do
|
|
|
+ if early |> Enum.empty?(),
|
|
|
+ do: socket |> assign(page_title: "Disponibilités vaccins"),
|
|
|
+ else: socket |> assign(page_title: "(!!) Disponibilités vaccins")
|
|
|
+ end
|
|
|
+
|
|
|
@impl true
|
|
|
def handle_params(%{}, _url, socket), do: {:noreply, socket}
|
|
|
|
|
|
@@ -62,18 +69,20 @@ defmodule VaccinsWeb.IndexLive do
|
|
|
do: {:noreply, socket |> trigger_periodic_refresh}
|
|
|
|
|
|
def handle_info({:location_has_slots, id, true}, socket) do
|
|
|
- {:noreply, socket |> update(:locations_with_early_slots, &(&1 |> MapSet.put(id)))}
|
|
|
+ {:noreply,
|
|
|
+ socket |> update(:locations_with_early_slots, &(&1 |> MapSet.put(id))) |> set_title}
|
|
|
end
|
|
|
|
|
|
def handle_info({:location_has_slots, id, false}, socket) do
|
|
|
- {:noreply, socket |> update(:locations_with_slots, &(&1 |> MapSet.put(id)))}
|
|
|
+ {:noreply, socket |> update(:locations_with_slots, &(&1 |> MapSet.put(id))) |> set_title}
|
|
|
end
|
|
|
|
|
|
def handle_info({:location_no_more_slots, id}, socket) do
|
|
|
{:noreply,
|
|
|
socket
|
|
|
|> update(:locations_with_slots, &(&1 |> MapSet.delete(id)))
|
|
|
- |> update(:locations_with_early_slots, &(&1 |> MapSet.delete(id)))}
|
|
|
+ |> update(:locations_with_early_slots, &(&1 |> MapSet.delete(id)))
|
|
|
+ |> set_title}
|
|
|
end
|
|
|
|
|
|
def handle_info({:location_deleted, _}, socket),
|