aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-05-31 20:53:12 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-05-31 20:54:08 +0200
commit2a16dcba5a31a45a12853a15254719c357baae6d (patch)
tree92271c8ce54846e684cd874c8c2008651c3a9778 /web
parentd8bdce51c336f3693121202402ee38ff3f12c0e2 (diff)
downloadWRMS-2a16dcba5a31a45a12853a15254719c357baae6d.tar.gz
WRMS-2a16dcba5a31a45a12853a15254719c357baae6d.zip
use an atomic pointer to track the current song
Also fix showing finished songs as current playing on new clients.
Diffstat (limited to 'web')
-rw-r--r--web/client.html10
1 files changed, 8 insertions, 2 deletions
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)