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