Skip to content

Commit

Permalink
refactor: move up handle_event call with others
Browse files Browse the repository at this point in the history
  • Loading branch information
meagharty committed Nov 20, 2024
1 parent f44180f commit f079692
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/arrow_web/live/shuttle_live/shuttle_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ defmodule ArrowWeb.ShuttleViewLive do
end
end

def handle_event("live_select_change", %{"text" => text, "id" => live_select_id}, socket) do
shapes =
Shuttles.list_shapes()
|> Enum.filter(&(String.downcase(&1.name) |> String.contains?(String.downcase(text))))
|> Enum.map(&option_mapper/1)

send_update(LiveSelect.Component, id: live_select_id, options: shapes)

{:noreply, socket}
end

def handle_event("add_stop", %{"value" => direction_id}, socket) do
direction_id = String.to_existing_atom(direction_id)

Expand Down Expand Up @@ -366,15 +377,4 @@ defmodule ArrowWeb.ShuttleViewLive do

{:noreply, assign(socket, form: form)}
end

def handle_event("live_select_change", %{"text" => text, "id" => live_select_id}, socket) do
shapes =
Shuttles.list_shapes()
|> Enum.filter(&(String.downcase(&1.name) |> String.contains?(String.downcase(text))))
|> Enum.map(&option_mapper/1)

send_update(LiveSelect.Component, id: live_select_id, options: shapes)

{:noreply, socket}
end
end

0 comments on commit f079692

Please sign in to comment.