ソースを参照

Prevent refresh while form is displayed

theenglishway (time) 4 年 前
コミット
645d844c65
1 ファイル変更5 行追加2 行削除
  1. 5 2
      lib/vaccins_web/live/index.ex

+ 5 - 2
lib/vaccins_web/live/index.ex

@@ -2,7 +2,7 @@ defmodule VaccinsWeb.IndexLive do
   use VaccinsWeb, :live_view
   alias Vaccins.{LocationStore, Search}
 
-  @refresh_period_ms 30 * 1000
+  @refresh_period_ms 2 * 1000
 
   @impl true
   def mount(_params, _session, socket) do
@@ -50,13 +50,16 @@ defmodule VaccinsWeb.IndexLive do
     {:noreply, socket |> assign(pending: pending |> Map.put(ref, id))}
   end
 
-  def handle_info(:periodic_refresh, socket),
+  def handle_info(:periodic_refresh, socket = %{assigns: %{display_cs: false}}),
     do:
       {:noreply,
        socket
        |> trigger_global_refresh
        |> trigger_periodic_refresh}
 
+  def handle_info(:periodic_refresh, socket = %{assigns: %{display_cs: true}}),
+    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)))}
   end