From 86840672358d8760e12e075c38dbdd20e3b45303 Mon Sep 17 00:00:00 2001
From: XShine555
Date: Thu, 16 Jul 2026 17:00:27 +0200
Subject: [PATCH] feat(frontend): hide empty local/YouTube sections when
searching in explore
---
.../src/routes/(app)/explore/+page.svelte | 187 +++++++++---------
1 file changed, 97 insertions(+), 90 deletions(-)
diff --git a/frontend/src/routes/(app)/explore/+page.svelte b/frontend/src/routes/(app)/explore/+page.svelte
index fdb84f5..ebe2d94 100644
--- a/frontend/src/routes/(app)/explore/+page.svelte
+++ b/frontend/src/routes/(app)/explore/+page.svelte
@@ -35,11 +35,20 @@
addedVideoIds = new Set();
});
- const showHeadings = $derived(!!data.query);
const tracks = $derived(data.tracks);
const currentPage = $derived(Number(data.tracks.pageNumber));
const total = $derived(Number(data.tracks.totalItemCount));
+ const localVisible = $derived(!data.query || tracks.items.length > 0);
+ const youtubeVisible = $derived(
+ !!data.query && (data.needsAuth || data.ytError || ytItems.length > 0)
+ );
+ const localHeadingVisible = $derived(!!data.query && localVisible);
+ const youtubeHeadingVisible = $derived(!!data.query && youtubeVisible);
+ const nothingFound = $derived(
+ !!data.query && !localVisible && !youtubeVisible && !data.needsAuth && !data.ytError
+ );
+
function buildHref(page = 1, query = data.query) {
const params = new URLSearchParams();
if (query) params.set('q', query);
@@ -137,95 +146,98 @@
{/if}
- {#if showHeadings}
-
- {#if data.query}
- {total}
- {total === 1 ? 'resultado' : 'resultados'} para «{data.query}»
- {:else}
- {total}
- {total === 1 ? 'canción' : 'canciones'}
- {/if}
-
-
- {#if tracks.items.length === 0}
-
-
-
- {#if data.query}
- No hay canciones tuyas que coincidan con «{data.query}».
- {:else}
- Todavía no hay canciones. ¡Sé el primero en subir una!
- {/if}
-
+ {#if nothingFound}
+
+
+
No hay resultados para «{data.query}».
- {:else}
-
- {#each tracks.items as track, i (track.id)}
-
- togglePlayLocal(i)} class="block w-full text-left">
-
-
- {#if player.current?.id === queueIdForTrack(track) && player.isPlaying}
-
-
-
- {:else}
-
-
-
- {/if}
-
-
-
- {track.title}
-
- {#if track.artist}
- {track.artist}
- {/if}
-
-
- {/each}
-
+ {/if}
- {#if tracks.hasPreviousPage || tracks.hasNextPage}
-
- {#if tracks.hasPreviousPage}
-
- Anterior
-
- {/if}
- Página {currentPage}
- {#if tracks.hasNextPage}
-
- Siguiente
-
- {/if}
-
+ {#if localVisible}
+ {#if localHeadingVisible}
+
Mi música
+ {/if}
+
+
+ {#if data.query}
+ {total}
+ {total === 1 ? 'resultado' : 'resultados'} para «{data.query}»
+ {:else}
+ {total}
+ {total === 1 ? 'canción' : 'canciones'}
+ {/if}
+
+
+ {#if tracks.items.length === 0}
+
+
+
Todavía no hay canciones. ¡Sé el primero en subir una!
+
+ {:else}
+
+ {#each tracks.items as track, i (track.id)}
+
+ togglePlayLocal(i)} class="block w-full text-left">
+
+
+ {#if player.current?.id === queueIdForTrack(track) && player.isPlaying}
+
+
+
+ {:else}
+
+
+
+ {/if}
+
+
+
+ {track.title}
+
+ {#if track.artist}
+ {track.artist}
+ {/if}
+
+
+ {/each}
+
+
+ {#if tracks.hasPreviousPage || tracks.hasNextPage}
+
+ {#if tracks.hasPreviousPage}
+
+ Anterior
+
+ {/if}
+ Página {currentPage}
+ {#if tracks.hasNextPage}
+
+ Siguiente
+
+ {/if}
+
+ {/if}
{/if}
{/if}
- {#if data.query}
- {#if showHeadings}
+ {#if youtubeVisible}
+ {#if youtubeHeadingVisible}
YouTube Music
{/if}
@@ -239,11 +251,6 @@
YouTube Music no está disponible ahora mismo. Inténtalo de nuevo.
- {:else if ytItems.length === 0}
-
-
-
No hay resultados en YouTube Music para «{data.query}».
-
{:else}