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 9c9174e commit 5ec7792
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 @@ -260,6 +260,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 @@ -323,15 +334,4 @@ defmodule ArrowWeb.ShuttleViewLive do
route_changeset
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
end

0 comments on commit 5ec7792

Please sign in to comment.