static: simplify Message update trigger

This commit is contained in:
Jens Langhammer 2020-10-16 20:11:24 +02:00
parent dfedd4a7f1
commit a18baa3cb3
3 changed files with 10 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ let ID = function (prefix) {
};
export function updateMessages() {
document.querySelector("pb-messages").setAttribute("touch", Date.now());
document.querySelector("pb-messages").fetchMessages();
}
class Messages extends LitElement {
@ -21,19 +21,18 @@ class Messages extends LitElement {
return {
url: { type: String },
messages: { type: Array },
touch: { type: Object },
};
}
set touch(value) {
this.firstUpdated();
}
createRenderRoot() {
return this;
}
firstUpdated() {
this.fetchMessages();
}
fetchMessages() {
return fetch(this.url).then(r => r.json()).then(r => this.messages = r).then((r) => {
const container = this.querySelector(".pf-c-alert-group");
r.forEach(message => {