forked from mirrors/bookwyrm
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
|
||||
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));
|
||||
}
|
||||
function updateCountElement(el, data) {
|
||||
const currentCount = el.innerHTML;
|
||||
const count = data[el.getAttribute('data-poll')];
|
||||
if (count) {
|
||||
if (count && count != currentCount) {
|
||||
removeClass(el, 'hidden');
|
||||
el.innerHTML = count;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue