add defensive empty tracks check in AlbumDetailView
Show a user-friendly i18n message with back button when an album loads without tracks, instead of displaying a blank track list. Uses album.loadError key in both en.json and es.json.
This commit is contained in:
1 parent
1dc61b50c5
commit
25dda16191
3 files changed
+40
-2
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, tick } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
|
import { t } from 'svelte-i18n';
|
||||||
import { ArrowLeft, Play, Shuffle, Heart, CloudDownload, ChevronLeft, ChevronRight } from 'lucide-svelte';
|
import { ArrowLeft, Play, Shuffle, Heart, CloudDownload, ChevronLeft, ChevronRight } from 'lucide-svelte';
|
||||||
import AlbumCard from '../AlbumCard.svelte';
|
import AlbumCard from '../AlbumCard.svelte';
|
||||||
import TrackRow from '../TrackRow.svelte';
|
import TrackRow from '../TrackRow.svelte';
|
||||||
@@ -424,6 +425,12 @@
|
|||||||
|
|
||||||
<!-- Track Rows -->
|
<!-- Track Rows -->
|
||||||
<div class="tracks">
|
<div class="tracks">
|
||||||
|
{#if !album.tracks || album.tracks.length === 0}
|
||||||
|
<div class="empty-tracks-message">
|
||||||
|
<p>{$t('album.loadError')}</p>
|
||||||
|
<button class="retry-btn" onclick={onBack}>{$t('actions.back')}</button>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
{#each album.tracks as track, trackIndex (`${track.id}-${downloadStateVersion}`)}
|
{#each album.tracks as track, trackIndex (`${track.id}-${downloadStateVersion}`)}
|
||||||
{@const downloadInfo = getTrackOfflineCacheStatus?.(track.id) ?? { status: 'none' as const, progress: 0 }}
|
{@const downloadInfo = getTrackOfflineCacheStatus?.(track.id) ?? { status: 'none' as const, progress: 0 }}
|
||||||
{@const isTrackDownloaded = downloadInfo.status === 'ready'}
|
{@const isTrackDownloaded = downloadInfo.status === 'ready'}
|
||||||
@@ -469,6 +476,7 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -879,4 +887,32 @@
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-tracks-message {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 32px 16px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-tracks-message p {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-btn {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-btn:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -185,7 +185,8 @@
|
|||||||
"addToPlaylist": "Add to Playlist",
|
"addToPlaylist": "Add to Playlist",
|
||||||
"makeAvailableOffline": "Make available offline",
|
"makeAvailableOffline": "Make available offline",
|
||||||
"makeAllAvailableOffline": "Make all available offline",
|
"makeAllAvailableOffline": "Make all available offline",
|
||||||
"disc": "Disc"
|
"disc": "Disc",
|
||||||
|
"loadError": "Could not load album tracks. Please try again."
|
||||||
},
|
},
|
||||||
"artist": {
|
"artist": {
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
|
|||||||
@@ -185,7 +185,8 @@
|
|||||||
"addToPlaylist": "Agregar a Lista",
|
"addToPlaylist": "Agregar a Lista",
|
||||||
"makeAvailableOffline": "Disponible offline",
|
"makeAvailableOffline": "Disponible offline",
|
||||||
"makeAllAvailableOffline": "Todo disponible offline",
|
"makeAllAvailableOffline": "Todo disponible offline",
|
||||||
"disc": "Disco"
|
"disc": "Disco",
|
||||||
|
"loadError": "No se pudieron cargar las pistas del album. Intenta de nuevo."
|
||||||
},
|
},
|
||||||
"artist": {
|
"artist": {
|
||||||
"albums": "Álbumes",
|
"albums": "Álbumes",
|
||||||
|
|||||||
Reference in new issue
Block a user