diff --git a/plugins/lyrics-genius/front.js b/plugins/lyrics-genius/front.js index 8a1802e4..e7d288e0 100644 --- a/plugins/lyrics-genius/front.js +++ b/plugins/lyrics-genius/front.js @@ -15,13 +15,22 @@ module.exports = () => { return; } + let hasLyrics = true; + const html = ipcRenderer.sendSync( "search-genius-lyrics", extractedSongInfo ); if (!html) { + // Delete previous lyrics if tab is open and couldn't get new lyrics + checkLyricsContainer(() => { + hasLyrics = false; + setTabsOnclick(undefined); + }); return; - } else if (is.dev()) { + } + + if (is.dev()) { console.log("Fetched lyrics from Genius"); } @@ -42,11 +51,7 @@ module.exports = () => { enableLyricsTab(); - for (tab of [tabs.upNext, tabs.discover]) { - if (tab) { - tab.onclick = enableLyricsTab; - } - } + setTabsOnclick(enableLyricsTab); checkLyricsContainer(); @@ -74,12 +79,22 @@ module.exports = () => { function setLyrics(lyricsContainer) { lyricsContainer.innerHTML = `
- ${lyrics} + ${hasLyrics ? lyrics : 'Subtitles could not be retrieved'}
`; - lyricsContainer.querySelector('.footer').textContent = 'Source: Genius'; - enableLyricsTab(); + if (hasLyrics) { + lyricsContainer.querySelector('.footer').textContent = 'Source: Genius'; + enableLyricsTab(); + } + } + + function setTabsOnclick(callback) { + for (tab of [tabs.upNext, tabs.discover]) { + if (tab) { + tab.onclick = callback; + } + } } function enableLyricsTab() {