diff options
author | vantezzen <properly@protonmail.com> | 2019-09-17 20:37:41 +0200 |
---|---|---|
committer | vantezzen <properly@protonmail.com> | 2019-09-17 20:37:41 +0200 |
commit | 16c183910c2917c58be39e6d25e64ea00cae38d4 (patch) | |
tree | 228058cee613a8987561104a4184ff5b0f244962 /src/stores/SettingsStore.js | |
parent | Update i18n (diff) | |
parent | Merge branch 'develop' (diff) | |
download | ferdium-app-16c183910c2917c58be39e6d25e64ea00cae38d4.tar.gz ferdium-app-16c183910c2917c58be39e6d25e64ea00cae38d4.tar.zst ferdium-app-16c183910c2917c58be39e6d25e64ea00cae38d4.zip |
Merge branch 'master' of https://github.com/meetfranz/franz into meetfranz-master
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r-- | src/stores/SettingsStore.js | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index f6a53f147..c09f24af7 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -1,12 +1,11 @@ | |||
1 | import { ipcRenderer, remote } from 'electron'; | 1 | import { ipcRenderer, remote } from 'electron'; |
2 | import { | 2 | import { |
3 | action, computed, observable, set, reaction, | 3 | action, computed, observable, reaction, |
4 | } from 'mobx'; | 4 | } from 'mobx'; |
5 | import localStorage from 'mobx-localstorage'; | 5 | import localStorage from 'mobx-localstorage'; |
6 | 6 | ||
7 | import Store from './lib/Store'; | 7 | import Store from './lib/Store'; |
8 | import Request from './lib/Request'; | 8 | import Request from './lib/Request'; |
9 | import CachedRequest from './lib/CachedRequest'; | ||
10 | import { getLocale } from '../helpers/i18n-helpers'; | 9 | import { getLocale } from '../helpers/i18n-helpers'; |
11 | import { API } from '../environment'; | 10 | import { API } from '../environment'; |
12 | 11 | ||
@@ -16,12 +15,8 @@ import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | |||
16 | const debug = require('debug')('Ferdi:SettingsStore'); | 15 | const debug = require('debug')('Ferdi:SettingsStore'); |
17 | 16 | ||
18 | export default class SettingsStore extends Store { | 17 | export default class SettingsStore extends Store { |
19 | @observable appSettingsRequest = new CachedRequest(this.api.local, 'getAppSettings'); | ||
20 | |||
21 | @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); | 18 | @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); |
22 | 19 | ||
23 | fileSystemSettingsRequests = []; | ||
24 | |||
25 | fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; | 20 | fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; |
26 | 21 | ||
27 | @observable _fileSystemSettingsCache = { | 22 | @observable _fileSystemSettingsCache = { |
@@ -36,14 +31,10 @@ export default class SettingsStore extends Store { | |||
36 | this.actions.settings.update.listen(this._update.bind(this)); | 31 | this.actions.settings.update.listen(this._update.bind(this)); |
37 | this.actions.settings.remove.listen(this._remove.bind(this)); | 32 | this.actions.settings.remove.listen(this._remove.bind(this)); |
38 | 33 | ||
39 | this.fileSystemSettingsTypes.forEach((type) => { | ||
40 | this.fileSystemSettingsRequests[type] = new CachedRequest(this.api.local, 'getAppSettings'); | ||
41 | }); | ||
42 | |||
43 | ipcRenderer.on('appSettings', (event, resp) => { | 34 | ipcRenderer.on('appSettings', (event, resp) => { |
44 | debug('Get appSettings resolves', resp.type, resp.data); | 35 | debug('Get appSettings resolves', resp.type, resp.data); |
45 | 36 | ||
46 | this._fileSystemSettingsCache[resp.type] = resp.data; | 37 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); |
47 | }); | 38 | }); |
48 | 39 | ||
49 | this.fileSystemSettingsTypes.forEach((type) => { | 40 | this.fileSystemSettingsTypes.forEach((type) => { |
@@ -52,8 +43,6 @@ export default class SettingsStore extends Store { | |||
52 | } | 43 | } |
53 | 44 | ||
54 | async setup() { | 45 | async setup() { |
55 | // 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 | ||
56 | await this.appSettingsRequest._promise; | ||
57 | await this._migrate(); | 46 | await this._migrate(); |
58 | 47 | ||
59 | reaction( | 48 | reaction( |
@@ -97,21 +86,6 @@ export default class SettingsStore extends Store { | |||
97 | } | 86 | } |
98 | 87 | ||
99 | @computed get proxy() { | 88 | @computed get proxy() { |
100 | // // We need to provide the final data structure as mobx autoruns won't work | ||
101 | // const proxySettings = observable({}); | ||
102 | // this.stores.services.all.forEach((service) => { | ||
103 | // proxySettings[service.id] = { | ||
104 | // isEnabled: false, | ||
105 | // host: null, | ||
106 | // user: null, | ||
107 | // password: null, | ||
108 | // }; | ||
109 | // }); | ||
110 | |||
111 | // debug('this._fileSystemSettingsCache.proxy', this._fileSystemSettingsCache.proxy, proxySettings); | ||
112 | |||
113 | // return Object.assign(proxySettings, this._fileSystemSettingsCache.proxy); | ||
114 | |||
115 | return this._fileSystemSettingsCache.proxy || {}; | 89 | return this._fileSystemSettingsCache.proxy || {}; |
116 | } | 90 | } |
117 | 91 | ||
@@ -153,7 +127,7 @@ export default class SettingsStore extends Store { | |||
153 | data, | 127 | data, |
154 | }); | 128 | }); |
155 | 129 | ||
156 | set(this._fileSystemSettingsCache[type], data); | 130 | Object.assign(this._fileSystemSettingsCache[type], data); |
157 | } | 131 | } |
158 | } | 132 | } |
159 | 133 | ||
@@ -234,8 +208,4 @@ export default class SettingsStore extends Store { | |||
234 | }); | 208 | }); |
235 | } | 209 | } |
236 | } | 210 | } |
237 | |||
238 | _getFileBasedSettings(type) { | ||
239 | ipcRenderer.send('getAppSettings', type); | ||
240 | } | ||
241 | } | 211 | } |