diff --git a/index.html b/index.html index efbfaa9..da8c652 100644 --- a/index.html +++ b/index.html @@ -193,6 +193,13 @@
${e.message}
`; } @@ -632,12 +637,22 @@ export async function quickPlayAlbum(a) { } // ─── STARRED / RANDOM ─── -export async function loadStarred() { +let _starredSort = 'newest'; + +export async function loadStarred(sort = _starredSort) { + _starredSort = sort; + document.querySelectorAll('#starred-sort-chips .sort-chip').forEach(c => + c.classList.toggle('active', c.dataset.sort === sort)); const el = document.getElementById('starred-songs'); el.innerHTML = ''; try { const r = await api('getStarred2'); - const songs = (r.starred2?.song || []).map(s => ({...s,_starred:true})); + let songs = (r.starred2?.song || []).map(s => ({...s, _starred: true})); + if (sort === 'newest') songs.sort((a, b) => new Date(b.starred||0) - new Date(a.starred||0)); + else if (sort === 'oldest') songs.sort((a, b) => new Date(a.starred||0) - new Date(b.starred||0)); + else if (sort === 'az') songs.sort((a, b) => (a.title||'').localeCompare(b.title||'')); + else if (sort === 'artist') songs.sort((a, b) => (a.artist||'').localeCompare(b.artist||'')); + else if (sort === 'plays') songs.sort((a, b) => (b.playCount||0) - (a.playCount||0)); el.innerHTML = ''; if(!songs.length) { el.innerHTML = 'Noch keine Favoriten