diff --git a/modules/web/web.js b/modules/web/web.js index bba016f..5b50c2d 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -85,34 +85,12 @@ function connectWs() { function wsSend(obj) { ws.send(JSON.stringify(obj)); } - -function gotLock() { - setTimeout(() => { - wsSend({action: "lock", "id": 0}); - wsSend({action: "get_toplay"}); - wsSend({action: "skipc"}); - wsSend({action: "skipi"}); - pollLockHeld = true; - }, 500 + (Math.random() * 2500)) -} - -function handleLockState(msg) { - if(msg[0] == true) pollLockHeld = false; - else gotLock(); -} - function handleMessage(msg) { switch (msg.event) { case "state": { const d = msg.data || {}; if(d.dirs) updateDirs(d.dirs); if(d.track) applyProgressState(d.track); - if(d.locks) handleLockState(d.locks) - break; - } - case "lock": { - if(msg.error) pollLockHeld = false; - else if (msg.id == 0 && msg.data == false) gotLock(); break; } case "rds": @@ -124,11 +102,9 @@ function handleMessage(msg) { break; case "new_track": applyTrackState(msg.data); - if(pollLockHeld) { - wsSend({ action: "get_toplay" }); - wsSend({ action: "skipc" }); - wsSend({ action: "skipi" }); - } + wsSend({ action: "get_toplay" }); + wsSend({ action: "skipc" }); + wsSend({ action: "skipi" }); break; case "progress": applyProgressState(msg.data);