X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2FMessage.vue;h=00ce158d7d96521930230bad7c6d23c3a1bbd8e4;hb=c4cae400d52c82986c78ae953ab8efcc94edcadc;hp=7c6acdde08919ea8f85f506ab37a496d1b153e69;hpb=66eace9e95d1962b437154b95e8f206d0da658ec;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) {