From 12a7c7732bd323d0524ea1bdae26383371bad56c Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 12 Jun 2023 21:50:10 +0400 Subject: [PATCH] Now if a list is emty and a table doesn't contains a tbody element it will be correctly created and a song will be added. --- web/assets/js/main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/assets/js/main.js b/web/assets/js/main.js index 9052b25..204a344 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -21,11 +21,10 @@ function updateLastPlayedSong() { fetch('/lastsong') .then(r => r.json()) .then(last_played => { - if (last_played.time == $('last-played').firstChild.lastChild.firstChild.innerText) - return; - if ($('last-played').firstChild === null) $('last-played').appendChild(document.createElement("tbody")) + else if (last_played.time == $('last-played').firstChild.lastChild.firstChild.innerText) + return; if ($('last-played').firstChild.children.length == 10) $('last-played').firstChild.firstChild.remove();