aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2021-04-21 22:09:01 -0700
committerBastien Wirtz <bastien.wirtz@gmail.com>2021-04-21 22:10:51 -0700
commit7596bc527f5b995bedd6a77ed71b6e1feba1364d (patch)
tree84ba285add9bcdd8c775042ff287893c9f4d6683 /src
parentaadd8b49ccb2eb19c8763a650c75debcb9146185 (diff)
downloadhomer-7596bc527f5b995bedd6a77ed71b6e1feba1364d.tar.gz
homer-7596bc527f5b995bedd6a77ed71b6e1feba1364d.tar.zst
homer-7596bc527f5b995bedd6a77ed71b6e1feba1364d.zip
Fix null error releated to refreshInterval + cleanup. Fix #210
Diffstat (limited to 'src')
-rw-r--r--src/components/Message.vue18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/components/Message.vue b/src/components/Message.vue
index 7c6acdd..6cc649a 100644
--- a/src/components/Message.vue
+++ b/src/components/Message.vue
@@ -42,19 +42,29 @@ export default {
42 }, 42 },
43 methods: { 43 methods: {
44 getMessage: async function () { 44 getMessage: async function () {
45 if (this.item && this.item.url) { 45 if (!this.item) {
46 return;
47 }
48 if (this.item.url) {
46 let fetchedMessage = await this.downloadMessage(this.item.url); 49 let fetchedMessage = await this.downloadMessage(this.item.url);
47 if (this.item.mapping) 50 console.log("done");
51 if (this.item.mapping) {
48 fetchedMessage = this.mapRemoteMessage(fetchedMessage); 52 fetchedMessage = this.mapRemoteMessage(fetchedMessage);
53 }
54
49 // keep the original config value if no value is provided by the endpoint 55 // keep the original config value if no value is provided by the endpoint
56 const message = this.message;
50 for (const prop of ["title", "style", "content"]) { 57 for (const prop of ["title", "style", "content"]) {
51 if (prop in fetchedMessage && fetchedMessage[prop] !== null) { 58 if (prop in fetchedMessage && fetchedMessage[prop] !== null) {
52 this.message[prop] = fetchedMessage[prop]; 59 message[prop] = fetchedMessage[prop];
53 } 60 }
54 } 61 }
62 this.message = { ...message }; // Force computed property to re-evaluate
55 } 63 }
56 if (this.item.refreshInterval) 64
65 if (this.item.refreshInterval) {
57 setTimeout(this.getMessage, this.item.refreshInterval); 66 setTimeout(this.getMessage, this.item.refreshInterval);
67 }
58 }, 68 },
59 69
60 downloadMessage: function (url) { 70 downloadMessage: function (url) {