diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Message.vue | 18 |
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) { |