diff options
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r-- | src/stores/SettingsStore.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 9270a6481..4b5715628 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -1,3 +1,4 @@ | |||
1 | import { remote } from 'electron'; | ||
1 | import { action, computed, observable } from 'mobx'; | 2 | import { action, computed, observable } from 'mobx'; |
2 | import localStorage from 'mobx-localstorage'; | 3 | import localStorage from 'mobx-localstorage'; |
3 | 4 | ||
@@ -6,6 +7,7 @@ import SettingsModel from '../models/Settings'; | |||
6 | import Request from './lib/Request'; | 7 | import Request from './lib/Request'; |
7 | import CachedRequest from './lib/CachedRequest'; | 8 | import CachedRequest from './lib/CachedRequest'; |
8 | 9 | ||
10 | const { systemPreferences } = remote; | ||
9 | const debug = require('debug')('SettingsStore'); | 11 | const debug = require('debug')('SettingsStore'); |
10 | 12 | ||
11 | export default class SettingsStore extends Store { | 13 | export default class SettingsStore extends Store { |
@@ -23,7 +25,7 @@ export default class SettingsStore extends Store { | |||
23 | async setup() { | 25 | async setup() { |
24 | // We need to wait until `appSettingsRequest` has been executed once, otherwise we can't patch the result. If we don't wait we'd run into an issue with mobx not reacting to changes of previously not existing keys | 26 | // We need to wait until `appSettingsRequest` has been executed once, otherwise we can't patch the result. If we don't wait we'd run into an issue with mobx not reacting to changes of previously not existing keys |
25 | await this.appSettingsRequest._promise; | 27 | await this.appSettingsRequest._promise; |
26 | this._migrate(); | 28 | await this._migrate(); |
27 | } | 29 | } |
28 | 30 | ||
29 | @computed get all() { | 31 | @computed get all() { |
@@ -67,7 +69,7 @@ export default class SettingsStore extends Store { | |||
67 | } | 69 | } |
68 | 70 | ||
69 | // Helper | 71 | // Helper |
70 | _migrate() { | 72 | async _migrate() { |
71 | const legacySettings = localStorage.getItem('app') || {}; | 73 | const legacySettings = localStorage.getItem('app') || {}; |
72 | 74 | ||
73 | if (!this.all.migration['5.0.0-beta.17-settings']) { | 75 | if (!this.all.migration['5.0.0-beta.17-settings']) { |
@@ -104,5 +106,26 @@ export default class SettingsStore extends Store { | |||
104 | 106 | ||
105 | debug('Migrated settings to split stores'); | 107 | debug('Migrated settings to split stores'); |
106 | } | 108 | } |
109 | |||
110 | // Enable dark mode once | ||
111 | if (!this.all.migration['5.0.0-beta.19-settings']) { | ||
112 | this.actions.settings.update({ | ||
113 | type: 'app', | ||
114 | data: { | ||
115 | darkMode: systemPreferences.isDarkMode(), | ||
116 | }, | ||
117 | }); | ||
118 | |||
119 | this.actions.settings.update({ | ||
120 | type: 'migration', | ||
121 | data: { | ||
122 | '5.0.0-beta.19-settings': true, | ||
123 | }, | ||
124 | }); | ||
125 | |||
126 | localStorage.removeItem('app'); | ||
127 | |||
128 | debug('Set up dark mode'); | ||
129 | } | ||
107 | } | 130 | } |
108 | } | 131 | } |