Background refresh

This commit is contained in:
Marcus Noble 2020-11-18 19:18:08 +00:00
parent c836fe576d
commit f6ebdc480e
1 changed files with 13 additions and 0 deletions

View File

@ -377,6 +377,19 @@
}
};
// Fetch updates every 5 minutes
setInterval(() => {
fetch(`/api/unread`)
.then(res => res.json())
.then(items => {
for (let item of items) {
if (!this.items.some(i => i.ID == item.ID)) {
this.items.push(item);
}
}
})
}, 5 * 60 * 1000);
document.addEventListener('keydown', this._keyListener.bind(this));
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {