mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-13 02:35:39 +00:00
Only update on change
This commit is contained in:
parent
128dc3be44
commit
3fce67a60d
1 changed files with 3 additions and 2 deletions
|
@ -34,7 +34,7 @@ window.onload = function() {
|
||||||
|
|
||||||
// polling
|
// polling
|
||||||
document.querySelectorAll('[data-poll]')
|
document.querySelectorAll('[data-poll]')
|
||||||
.forEach(t => setInterval(function () { polling(t) }, 10000));
|
.forEach(t => setInterval(function () { polling(t); }, 10000));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,8 +46,9 @@ function polling(el) {
|
||||||
.then(data => updateCountElement(el, data));
|
.then(data => updateCountElement(el, data));
|
||||||
}
|
}
|
||||||
function updateCountElement(el, data) {
|
function updateCountElement(el, data) {
|
||||||
|
const currentCount = el.innerHTML;
|
||||||
const count = data[el.getAttribute('data-poll')];
|
const count = data[el.getAttribute('data-poll')];
|
||||||
if (count) {
|
if (count && count != currentCount) {
|
||||||
removeClass(el, 'hidden');
|
removeClass(el, 'hidden');
|
||||||
el.innerHTML = count;
|
el.innerHTML = count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue