From 9d255d9c54dd68b550024931ed0774ff7d1ade24 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 17 Sep 2019 11:24:36 +0200 Subject: cleanup settings store --- src/stores/SettingsStore.js | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'src/stores/SettingsStore.js') diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index a456195bf..75bb38fe0 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -1,12 +1,11 @@ import { ipcRenderer } from 'electron'; import { - action, computed, observable, set, + action, computed, observable, } from 'mobx'; import localStorage from 'mobx-localstorage'; import Store from './lib/Store'; import Request from './lib/Request'; -import CachedRequest from './lib/CachedRequest'; import { getLocale } from '../helpers/i18n-helpers'; import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config'; @@ -15,12 +14,8 @@ import { SPELLCHECKER_LOCALES } from '../i18n/languages'; const debug = require('debug')('Franz:SettingsStore'); export default class SettingsStore extends Store { - @observable appSettingsRequest = new CachedRequest(this.api.local, 'getAppSettings'); - @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); - fileSystemSettingsRequests = []; - fileSystemSettingsTypes = FILE_SYSTEM_SETTINGS_TYPES; @observable _fileSystemSettingsCache = { @@ -35,14 +30,10 @@ export default class SettingsStore extends Store { this.actions.settings.update.listen(this._update.bind(this)); this.actions.settings.remove.listen(this._remove.bind(this)); - this.fileSystemSettingsTypes.forEach((type) => { - this.fileSystemSettingsRequests[type] = new CachedRequest(this.api.local, 'getAppSettings'); - }); - ipcRenderer.on('appSettings', (event, resp) => { debug('Get appSettings resolves', resp.type, resp.data); - this._fileSystemSettingsCache[resp.type] = resp.data; + Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); }); this.fileSystemSettingsTypes.forEach((type) => { @@ -51,8 +42,6 @@ export default class SettingsStore extends Store { } async setup() { - // 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 - await this.appSettingsRequest._promise; await this._migrate(); } @@ -61,21 +50,6 @@ export default class SettingsStore extends Store { } @computed get proxy() { - // // We need to provide the final data structure as mobx autoruns won't work - // const proxySettings = observable({}); - // this.stores.services.all.forEach((service) => { - // proxySettings[service.id] = { - // isEnabled: false, - // host: null, - // user: null, - // password: null, - // }; - // }); - - // debug('this._fileSystemSettingsCache.proxy', this._fileSystemSettingsCache.proxy, proxySettings); - - // return Object.assign(proxySettings, this._fileSystemSettingsCache.proxy); - return this._fileSystemSettingsCache.proxy || {}; } @@ -117,7 +91,7 @@ export default class SettingsStore extends Store { data, }); - set(this._fileSystemSettingsCache[type], data); + Object.assign(this._fileSystemSettingsCache[type], data); } } @@ -197,8 +171,4 @@ export default class SettingsStore extends Store { }); } } - - _getFileBasedSettings(type) { - ipcRenderer.send('getAppSettings', type); - } } -- cgit v1.2.3-54-g00ecf