diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2019-10-07 22:32:30 -0700 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2019-10-07 22:32:30 -0700 |
commit | d6adb2db1b20fcd3e1ad50bfab8324d0ab2f714f (patch) | |
tree | 270cd4c8535286257a831b3a44cbaa0438bf7a1b /app.js | |
parent | 1312fe5d1a44657ced6b2b92a870cacab1311d99 (diff) | |
download | homer-d6adb2db1b20fcd3e1ad50bfab8324d0ab2f714f.tar.gz homer-d6adb2db1b20fcd3e1ad50bfab8324d0ab2f714f.tar.zst homer-d6adb2db1b20fcd3e1ad50bfab8324d0ab2f714f.zip |
Implementing settings persistence.
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -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 | ||