Browse Source

wip: Send id instead of ref

theenglishway (time) 4 years ago
parent
commit
d54f49253a
2 changed files with 6 additions and 0 deletions
  1. 1 0
      lib/vaccins/search.ex
  2. 5 0
      lib/vaccins_web/live/index.ex

+ 1 - 0
lib/vaccins/search.ex

@@ -11,6 +11,7 @@ defmodule Vaccins.Search do
     with {:ok, _} <-
            Task.start(fn ->
              send(target, {:query_result, ref, l |> Location.query_availability()})
+             send(target, {:location_availabilities, l.id, l |> Location.query_availability()})
            end),
          do: ref
   end

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

@@ -110,6 +110,11 @@ defmodule VaccinsWeb.IndexLive do
     {:noreply, socket |> assign(pending: pending |> Map.delete(ref))}
   end
 
+  def handle_info({:location_availabilities, id, res}, socket = %{assigns: %{locations: valid}}) do
+    send_update(VaccinsWeb.LocationComponent, id: id, availabilities: res)
+    {:noreply, socket}
+  end
+
   defp trigger_global_refresh(socket = %{assigns: %{locations: locations}}) do
     locations
     |> Enum.each(&send_update(VaccinsWeb.LocationComponent, id: &1.id, force_refresh: true))