Remove custom loading state logic

This commit is contained in:
Claudio Ortolina
2025-07-06 09:44:42 +01:00
parent 745bc88061
commit 3787736e39
5 changed files with 4 additions and 39 deletions
@@ -235,20 +235,4 @@ defmodule MusicLibraryWeb.SearchComponents do
</div>
"""
end
@doc """
Renders a loading state.
## Examples
<.loading_state />
"""
def loading_state(assigns) do
~H"""
<div class="p-8 text-center">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"></div>
<p class="mt-4 text-zinc-600 dark:text-zinc-400">{gettext("Searching...")}</p>
</div>
"""
end
end
@@ -13,7 +13,6 @@ defmodule MusicLibraryWeb.UniversalSearchLive.Index do
|> assign(:search_results, %{collection: [], wishlist: [], artists: []})
|> assign(:search_counts, %{collection_count: 0, wishlist_count: 0, artists_count: 0})
|> assign(:show_modal, false)
|> assign(:loading, false)
|> assign(:total_results, 0)}
end
@@ -43,12 +42,11 @@ defmodule MusicLibraryWeb.UniversalSearchLive.Index do
socket
|> assign(:search_results, %{collection: [], wishlist: [], artists: []})
|> assign(:search_counts, %{collection_count: 0, wishlist_count: 0, artists_count: 0})
|> assign(:loading, false)
|> assign(:total_results, 0)}
_query ->
send(self(), {:perform_search, query})
{:noreply, assign(socket, :loading, true)}
{:noreply, socket}
end
end
@@ -123,7 +121,6 @@ defmodule MusicLibraryWeb.UniversalSearchLive.Index do
socket
|> assign(:search_results, search_results)
|> assign(:search_counts, search_counts)
|> assign(:loading, false)
|> assign(:total_results, total_results)}
else
{:noreply, socket}
@@ -22,20 +22,14 @@
</div>
</form>
<!-- Loading state -->
<.loading_state :if={@loading} />
<!-- Empty state -->
<.empty_state :if={@search_query == "" and not @loading} />
<.empty_state :if={@search_query == ""} />
<!-- No results -->
<.no_results
:if={@search_query != "" and @total_results == 0 and not @loading}
query={@search_query}
/>
<.no_results :if={@search_query != "" and @total_results == 0} query={@search_query} />
<!-- Search results -->
<div :if={@total_results > 0 and not @loading} class="max-h-96 overflow-y-auto">
<div :if={@total_results > 0} class="max-h-96 overflow-y-auto">
<!-- Collection results -->
<.search_result_group
:if={length(@search_results.collection) > 0}
-5
View File
@@ -1128,11 +1128,6 @@ msgstr ""
msgid "No results found for '%{query}'"
msgstr ""
#: lib/music_library_web/components/search_components.ex
#, elixir-autogen, elixir-format
msgid "Searching..."
msgstr ""
#: lib/music_library_web/components/search_components.ex
#, elixir-autogen, elixir-format
msgid "View all %{count} %{target} results →"
-5
View File
@@ -1128,11 +1128,6 @@ msgstr ""
msgid "No results found for '%{query}'"
msgstr ""
#: lib/music_library_web/components/search_components.ex
#, elixir-autogen, elixir-format, fuzzy
msgid "Searching..."
msgstr ""
#: lib/music_library_web/components/search_components.ex
#, elixir-autogen, elixir-format
msgid "View all %{count} %{target} results →"