Rotate immediately if waitUntil is in the past

This commit is contained in:
Henri Bergius 2018-12-26 21:10:10 +01:00
parent b589e07bae
commit 5b6e323a90

View file

@ -85,13 +85,16 @@ function DisplayParticipant(broker, role, defaultUrls, timer) {
window.onmessage = null;
const now = new Date();
if (!event.data
|| !event.data.waitUntil
|| event.data.waitUntil < now.getTime()) {
|| !event.data.waitUntil) {
return;
}
if (timeout) {
clearTimeout(timeout);
}
if (event.data.waitUntil < now.getTime()) {
participant.send('open', getRotationUrl(urls, indata));
return;
}
timeout = setTimeout(() => {
participant.send('open', getRotationUrl(urls, indata));
}, event.data.waitUntil - now.getTime());