Merge pull request #599 from mouse-reeve/notifications-backoff

Back off notification polling
This commit is contained in:
Mouse Reeve 2021-02-09 10:59:00 -08:00 committed by GitHub
commit 482c464979
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,13 +46,14 @@ function back(e) {
history.back();
}
function polling(el) {
let delay = 10000 + (Math.random() * 1000);
function polling(el, delay) {
delay = delay || 10000;
delay += (Math.random() * 1000);
setTimeout(function() {
fetch('/api/updates/' + el.getAttribute('data-poll'))
.then(response => response.json())
.then(data => updateCountElement(el, data));
polling(el);
polling(el, delay * 1.25);
}, delay, el);
}