anonradio: fix timer dying

This commit is contained in:
Cynthia Foxwell 2022-12-21 16:46:13 -07:00
parent ea18e21d42
commit 5b04ce97a9
1 changed files with 8 additions and 2 deletions

View File

@ -38,13 +38,19 @@ async function updateNowPlaying() {
} }
} }
if (!playing || !schedule) return; if (!playing || !schedule) {
hf.__anonradio_timeout = setTimeout(updateNowPlaying, 2000);
return;
}
let lines = schedule.split("\n"); let lines = schedule.split("\n");
lines = lines.slice(4, lines.length - 2); lines = lines.slice(4, lines.length - 2);
const line = lines[0]; const line = lines[0];
if (!line) return; if (!line) {
hf.__anonradio_timeout = setTimeout(updateNowPlaying, 2000);
return;
}
const [_, _time, id, name] = line.match(/^(.{3,4} .{4})\s+(.+?) {2}(.+?)$/); const [_, _time, id, name] = line.match(/^(.{3,4} .{4})\s+(.+?) {2}(.+?)$/);