aboutsummaryrefslogtreecommitdiffhomepage
path: root/app.js
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2019-10-08 08:04:09 -0700
committerGitHub <noreply@github.com>2019-10-08 08:04:09 -0700
commit89c89a0db70a2cfa41ea6a2c523e58a2c5dd3116 (patch)
tree270cd4c8535286257a831b3a44cbaa0438bf7a1b /app.js
parent1312fe5d1a44657ced6b2b92a870cacab1311d99 (diff)
parentd6adb2db1b20fcd3e1ad50bfab8324d0ab2f714f (diff)
downloadhomer-89c89a0db70a2cfa41ea6a2c523e58a2c5dd3116.tar.gz
homer-89c89a0db70a2cfa41ea6a2c523e58a2c5dd3116.tar.zst
homer-89c89a0db70a2cfa41ea6a2c523e58a2c5dd3116.zip
Merge pull request #3 from bastienwirtz/localstorage-settings
Implementing settings persistence.
Diffstat (limited to 'app.js')
-rw-r--r--app.js25
1 files changed, 15 insertions, 10 deletions
diff --git a/app.js b/app.js
index a404314..41bdd9d 100644
--- a/app.js
+++ b/app.js
@@ -5,11 +5,18 @@ const app = new Vue({
5 offline: false, 5 offline: false,
6 filter: '', 6 filter: '',
7 vlayout: true, 7 vlayout: true,
8 overrideDark: null 8 isDark: null
9 }, 9 },
10 created: function () { 10 created: function () {
11 let that = this; 11 let that = this;
12
13 this.isDark = 'overrideDark' in localStorage ?
14 JSON.parse(localStorage.overrideDark) : matchMedia("(prefers-color-scheme: dark)").matches;
12 15
16 if ('vlayout' in localStorage) {
17 this.vlayout = JSON.parse(localStorage.vlayout)
18 }
19
13 this.checkOffline(); 20 this.checkOffline();
14 that.getConfig().then(function (config) { 21 that.getConfig().then(function (config) {
15 that.config = config; 22 that.config = config;
@@ -23,13 +30,6 @@ const app = new Vue({
23 } 30 }
24 }, false); 31 }, false);
25 }, 32 },
26 computed: {
27 isDark: function() {
28 return this.overrideDark !== null
29 ? this.overrideDark
30 : matchMedia("(prefers-color-scheme: dark)").matches;
31 }
32 },
33 methods: { 33 methods: {
34 checkOffline: function () { 34 checkOffline: function () {
35 let that = this; 35 let that = this;
@@ -53,8 +53,13 @@ const app = new Vue({
53 }); 53 });
54 }, 54 },
55 toggleTheme: function() { 55 toggleTheme: function() {
56 this.overrideDark = !this.isDark; 56 this.isDark = !this.isDark;
57 } 57 localStorage.overrideDark = this.isDark;
58 },
59 toggleLayout: function() {
60 this.vlayout = !this.vlayout;
61 localStorage.vlayout = this.vlayout;
62 },
58 } 63 }
59}); 64});
60 65