Changeset 795c925 in Klonkt for src/services/PlaylistService.js


Ignore:
Timestamp:
06/20/2026 02:20:53 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1ee967d
Parents:
5258945
Message:

fix(playlist): album/playlist cover falls back to first track cover

PlaylistService.get returned cover= when the playlist had no own cover_url
→ empty card. Now falls back to the cover of the first track that has one.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/PlaylistService.js

    r5258945 r795c925  
    102102    `).all(id);
    103103
     104    const mappedTracks = tracks
     105      .filter(t => t.filename)  // skip orphaned references
     106      .map(t => ({
     107        id: t.id,
     108        title: t.title || 'Untitled',
     109        artist: t.artist || p.artist || '',
     110        cover: t.cover_url || p.cover_url || '',
     111        duration: t.duration || 0,
     112        url: urlFor ? urlFor(t.filename) : null,
     113      }));
     114    // Geen eigen cover? Val terug op de eerste track-cover, zodat de kaart niet leeg is.
     115    const fallbackCover = (mappedTracks.find(t => t.cover) || {}).cover || '';
    104116    return {
    105117      id: p.id,
     
    107119      artist: p.artist || '',
    108120      year: p.year || 0,
    109       cover: p.cover_url || '',
     121      cover: p.cover_url || fallbackCover,
    110122      kind: (p.kind === 'playlist') ? 'playlist' : 'album',
    111       tracks: tracks
    112         .filter(t => t.filename)  // skip orphaned references
    113         .map(t => ({
    114           id: t.id,
    115           title: t.title || 'Untitled',
    116           artist: t.artist || p.artist || '',
    117           cover: t.cover_url || p.cover_url || '',
    118           duration: t.duration || 0,
    119           url: urlFor ? urlFor(t.filename) : null,
    120         })),
     123      tracks: mappedTracks,
    121124    };
    122125  }
Note: See TracChangeset for help on using the changeset viewer.