Rotate immediately if waitUntil is in the past
This commit is contained in:
parent
b589e07bae
commit
5b6e323a90
1 changed files with 5 additions and 2 deletions
|
@ -85,13 +85,16 @@ function DisplayParticipant(broker, role, defaultUrls, timer) {
|
||||||
window.onmessage = null;
|
window.onmessage = null;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (!event.data
|
if (!event.data
|
||||||
|| !event.data.waitUntil
|
|| !event.data.waitUntil) {
|
||||||
|| event.data.waitUntil < now.getTime()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
if (event.data.waitUntil < now.getTime()) {
|
||||||
|
participant.send('open', getRotationUrl(urls, indata));
|
||||||
|
return;
|
||||||
|
}
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
participant.send('open', getRotationUrl(urls, indata));
|
participant.send('open', getRotationUrl(urls, indata));
|
||||||
}, event.data.waitUntil - now.getTime());
|
}, event.data.waitUntil - now.getTime());
|
||||||
|
|
Loading…
Reference in a new issue