Skip to content

Commit

Permalink
fix pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
cbh123 committed Sep 27, 2023
1 parent 0ab7e86 commit 693aa57
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/emoji_web/live/search_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ defmodule EmojiWeb.SearchLive do
end

@impl true
def handle_params(%{"q" => query}, _uri, socket) do
Task.async(fn -> Emoji.Embeddings.search_emojis(query, @num_results, false) end)
def handle_params(%{"q" => query, "search_via_images" => search_via_images}, _uri, socket) do
Task.async(fn ->
Emoji.Embeddings.search_emojis(query, @num_results, search_via_images == "true")
end)

{:noreply,
socket
|> assign(
loading: true,
form: to_form(%{"query" => query})
form: to_form(%{"query" => query, "search_via_images" => search_via_images})
)}
end

@impl true
def handle_params(%{"q" => query, "search_via_images" => search_via_images}, _uri, socket) do
Task.async(fn ->
Emoji.Embeddings.search_emojis(query, @num_results, search_via_images == "true")
end)
def handle_params(%{"q" => query}, _uri, socket) do
Task.async(fn -> Emoji.Embeddings.search_emojis(query, @num_results, false) end)

{:noreply,
socket
|> assign(
loading: true,
form: to_form(%{"query" => query, "search_via_images" => search_via_images})
form: to_form(%{"query" => query})
)}
end

Expand Down

0 comments on commit 693aa57

Please sign in to comment.