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() {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user