mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-20 00:21:04 +00:00
Merge pull request #599 from mouse-reeve/notifications-backoff
Back off notification polling
This commit is contained in:
commit
482c464979
1 changed files with 4 additions and 3 deletions
|
@ -46,13 +46,14 @@ function back(e) {
|
||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
function polling(el) {
|
function polling(el, delay) {
|
||||||
let delay = 10000 + (Math.random() * 1000);
|
delay = delay || 10000;
|
||||||
|
delay += (Math.random() * 1000);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fetch('/api/updates/' + el.getAttribute('data-poll'))
|
fetch('/api/updates/' + el.getAttribute('data-poll'))
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => updateCountElement(el, data));
|
.then(data => updateCountElement(el, data));
|
||||||
polling(el);
|
polling(el, delay * 1.25);
|
||||||
}, delay, el);
|
}, delay, el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue