Skip to content

Commit

Permalink
Show last viewed playlist on start
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Apr 23, 2020
1 parent f6722a7 commit 9321021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
})
Expand Down

0 comments on commit 9321021

Please sign in to comment.