From 2a16dcba5a31a45a12853a15254719c357baae6d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 31 May 2023 20:53:12 +0200 Subject: use an atomic pointer to track the current song Also fix showing finished songs as current playing on new clients. --- web/client.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/client.html b/web/client.html index 91ce11d..c0aef1f 100644 --- a/web/client.html +++ b/web/client.html @@ -202,9 +202,15 @@ playing = document.getElementById("playing").innerHTML = ""; } - function handlePlay(currentSong) { + function handlePlay(_currentSongs) { {{if .IsAdmin}} document.getElementById("ppbutton").innerHTML = 'Pause'; {{end}} + if (_currentSongs == null || _currentSongs.length == 0) { + return; + } + + const currentSong = _currentSongs[0] + idx = -1; songs.forEach(function(s, i, a) { if (s.uri == currentSong.uri) idx = i; }); if (idx != -1) { @@ -251,7 +257,7 @@ handleStop() break; case "play": - handlePlay(cmd.songs[0]) + handlePlay(cmd.songs) break; case "upvoted": handleVotes("up", cmd.songs) -- cgit v1.2.3