1
0

In main.js just call updateStatus() without waiting if there is a current song.

This commit is contained in:
Alexander Andreev 2023-10-09 01:44:46 +04:00
parent 1d7cce75d5
commit bc85efb3db
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -55,15 +55,15 @@ async function updateStatus() {
async function update() {
if (null === cursong_startat)
return false;
return -1;
const estimate = (new Date()) - (new Date(cursong_startat));
if (estimate >= cursong_duration_msec) {
return false;
return 1;
}
$("radio-duration-estimate").textContent = `${formatDuration(new Date(estimate))} / `;
return true;
return 0;
}
$("radio-update").addEventListener("click", async () =>
@ -72,7 +72,11 @@ $("radio-update").addEventListener("click", async () =>
let update_interval_id = null;
async function interval() {
if (!await update()) {
switch (await update()) {
case 1:
[cursong_duration_msec, cursong_startat] = await updateStatus();
break;
case -1:
clearInterval(update_interval_id);
await new Promise(resolve => setTimeout(resolve, 5000));
[cursong_duration_msec, cursong_startat] = await updateStatus();