X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcomponents%2FMessage.vue;h=00ce158d7d96521930230bad7c6d23c3a1bbd8e4;hb=077be43473ebdb241c6a70e4d06795ca80a591fb;hp=7c6acdde08919ea8f85f506ab37a496d1b153e69;hpb=ba07da6b1011e77c9ed42e8643e62b903c6c6d7b;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/Message.vue b/src/components/Message.vue index 7c6acdd..00ce158 100644 --- a/src/components/Message.vue +++ b/src/components/Message.vue @@ -42,19 +42,29 @@ export default { }, methods: { getMessage: async function () { - if (this.item && this.item.url) { + if (!this.item) { + return; + } + if (this.item.url) { let fetchedMessage = await this.downloadMessage(this.item.url); - if (this.item.mapping) + console.log("done"); + if (this.item.mapping) { fetchedMessage = this.mapRemoteMessage(fetchedMessage); + } + // keep the original config value if no value is provided by the endpoint - for (const prop of ["title", "style", "content"]) { + const message = this.message; + for (const prop of ["title", "style", "content", "icon"]) { if (prop in fetchedMessage && fetchedMessage[prop] !== null) { - this.message[prop] = fetchedMessage[prop]; + message[prop] = fetchedMessage[prop]; } } + this.message = { ...message }; // Force computed property to re-evaluate } - if (this.item.refreshInterval) + + if (this.item.refreshInterval) { setTimeout(this.getMessage, this.item.refreshInterval); + } }, downloadMessage: function (url) {