static: simplify Message update trigger
This commit is contained in:
parent
dfedd4a7f1
commit
a18baa3cb3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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 => {
|
||||
|
|
Reference in New Issue