diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c3065..c12aa9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## WIP - Major performance improvements - Search box improvements +- Show last viewed playlist on start - Fix position of error box ## 1.0.3 diff --git a/src/js/app.js b/src/js/app.js index 1f9ad2f..e644e04 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -41,12 +41,15 @@ async function fetchPlaylists() { const playlist = document.createElement('a') const span = document.createElement('span') playlist.setAttribute('href', '#') + playlist.setAttribute('data-playlist-id', value.playlist_id) playlist.classList.add('playlist-item') playlist.innerHTML = `${icons.playlist}` span.innerText = `${value.name}` playlist.append(span) playlist.addEventListener('click', ({ currentTarget }) => { + store.set('last-playlist', currentTarget.getAttribute('data-playlist-id')) + // Remove current 'active' class const active = document.querySelector('.active') if (active !== null) { @@ -90,6 +93,11 @@ async function fetchPlaylists() { .then((response) => { tracks = response }) + .then(() => { + if (store.get('last-playlist') !== undefined) { + document.querySelector(`[data-playlist-id="${store.get('last-playlist')}"]`).click() + } + }) .then(() => { table.sort() })