Clean up, fix filters

This commit is contained in:
Harshad Sharma 2024-05-16 07:34:09 +05:30
parent 9f6e3ddab2
commit 74615f5ac7

View file

@ -61,6 +61,7 @@ defmodule FreediveWeb.LiliformLive do
def(handle_event("tap", %{"name" => item_name}, socket)) do
# 1 tap to select, 2 taps for details
item = socket.assigns.items[item_name]
socket =
case socket.assigns.selected_item do
nil ->
@ -81,8 +82,6 @@ defmodule FreediveWeb.LiliformLive do
assign(socket, %{selected_item: item, details: nil})
end
end
IO.inspect(socket.assigns.selected_item, label: "selected_item")
IO.inspect(socket.assigns.details, label: "details")
{:noreply, socket}
end
end
@ -98,10 +97,7 @@ defmodule FreediveWeb.LiliformLive do
items
_ ->
Enum.filter(items, fn {_, item} ->
Map.get(item, key) == true
end)
Enum.into(%{}, items)
items |> Enum.filter(fn {_name, item} -> item[key] == true end)
end
end