From 76491e4e35c2bceeb143091ab9c04e8fcf5347f8 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 9 Feb 2021 10:38:43 -0800 Subject: [PATCH] Back off notification polling --- bookwyrm/static/js/shared.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index c2fa8b541..758b76dc1 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -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); }