From: Bastien Wirtz Date: Fri, 27 Dec 2019 18:39:44 +0000 (-0800) Subject: Merge branch 'master' into dynamic-message X-Git-Tag: v1.0~14^2 X-Git-Url: https://git.immae.eu/?p=github%2Fbastienwirtz%2Fhomer.git;a=commitdiff_plain;h=db409f74e016b35421c2aaa2a5ade1e42553664e Merge branch 'master' into dynamic-message --- db409f74e016b35421c2aaa2a5ade1e42553664e diff --cc app.js index 93902d8,40830da..6c2ba90 --- a/app.js +++ b/app.js @@@ -7,34 -7,22 +7,34 @@@ const app = new Vue( vlayout: true, isDark: null }, - created: function () { + created: async function () { let that = this; - this.isDark = 'overrideDark' in localStorage ? + this.isDark = 'overrideDark' in localStorage ? JSON.parse(localStorage.overrideDark) : matchMedia("(prefers-color-scheme: dark)").matches; if ('vlayout' in localStorage) { this.vlayout = JSON.parse(localStorage.vlayout) } - + this.checkOffline(); - that.getConfig().then(function (config) { - that.config = config; - }).catch(function () { - that.offline = true; - }); + try { + this.config = await this.getConfig(); + } catch (error) { + this.offline = true; + } + + // Look for a new message if an endpoint is provided. + if (this.config.message.url) { + this.getMessage(this.config.message.url).then(function(message){ + // keep the original config value if no value is provided by the endpoint + for (const prop of ['title','style','content']) { + if (prop in message && message[prop] !== null) { + that.config.message[prop] = message[prop]; + } + } + }); + } document.addEventListener('visibilitychange', function () { if (document.visibilityState == "visible") {