chore: simplify now playing

This commit is contained in:
Cory Dransfeldt 2023-10-07 11:57:00 -07:00
parent 06ca81b903
commit 282bc3a84d
3 changed files with 10 additions and 10 deletions

View file

@ -1,14 +1,13 @@
;(async function () {
const nowPlaying = document.getElementById('now-playing')
if (nowPlaying) {
const emoji = document.getElementById('now-playing-emoji')
const content = document.getElementById('now-playing-content')
const loading = document.getElementById('now-playing-loading')
const populateNowPlaying = (data) => {
loading.style.display = 'none'
emoji.innerText = data.emoji
content.innerText = `${data.title} by ${data.artist}`
emoji.classList.remove('hidden')
content.innerText = data.text
content.classList.remove('hidden')
}
@ -19,12 +18,13 @@
/* quiet catch */
}
const res = await fetch('/api/now-playing', {
const data = await fetch('/api/now-playing', {
type: 'json',
}).catch(() => {
loading.style.display = 'none'
})
const data = await res.json()
.then((data) => data.json())
.catch(() => {
loading.style.display = 'none'
})
try {
localStorage.setItem('now-playing', JSON.stringify(data))