In main.js just call updateStatus() without waiting if there is a current song.
This commit is contained in:
parent
1d7cce75d5
commit
bc85efb3db
@ -55,15 +55,15 @@ async function updateStatus() {
|
|||||||
|
|
||||||
async function update() {
|
async function update() {
|
||||||
if (null === cursong_startat)
|
if (null === cursong_startat)
|
||||||
return false;
|
return -1;
|
||||||
|
|
||||||
const estimate = (new Date()) - (new Date(cursong_startat));
|
const estimate = (new Date()) - (new Date(cursong_startat));
|
||||||
if (estimate >= cursong_duration_msec) {
|
if (estimate >= cursong_duration_msec) {
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("radio-duration-estimate").textContent = `${formatDuration(new Date(estimate))} / `;
|
$("radio-duration-estimate").textContent = `${formatDuration(new Date(estimate))} / `;
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("radio-update").addEventListener("click", async () =>
|
$("radio-update").addEventListener("click", async () =>
|
||||||
@ -72,11 +72,15 @@ $("radio-update").addEventListener("click", async () =>
|
|||||||
|
|
||||||
let update_interval_id = null;
|
let update_interval_id = null;
|
||||||
async function interval() {
|
async function interval() {
|
||||||
if (!await update()) {
|
switch (await update()) {
|
||||||
clearInterval(update_interval_id);
|
case 1:
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
[cursong_duration_msec, cursong_startat] = await updateStatus();
|
||||||
[cursong_duration_msec, cursong_startat] = await updateStatus();
|
break;
|
||||||
update_interval_id = setInterval(interval, 1000);
|
case -1:
|
||||||
|
clearInterval(update_interval_id);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||||
|
[cursong_duration_msec, cursong_startat] = await updateStatus();
|
||||||
|
update_interval_id = setInterval(interval, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user