aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/SettingsStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-23 11:30:19 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-11-23 11:30:19 +0100
commit5573ab7e17400229dd5d79fa50808b38293872fc (patch)
treed1f933f081032a2bff4965033087f2ed2bfcecf9 /src/stores/SettingsStore.js
parenttest tweetdeck glitches (diff)
downloadferdium-app-5573ab7e17400229dd5d79fa50808b38293872fc.tar.gz
ferdium-app-5573ab7e17400229dd5d79fa50808b38293872fc.tar.zst
ferdium-app-5573ab7e17400229dd5d79fa50808b38293872fc.zip
Add SettingsModel and fix issue with improper mobx data handling
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r--src/stores/SettingsStore.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index ad3c53ccf..30058f41d 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,11 +1,10 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import { action, computed, observable } from 'mobx'; 2import { action, computed, observable, extendObservable } from 'mobx';
3 3
4import Store from './lib/Store'; 4import Store from './lib/Store';
5import Request from './lib/Request'; 5import Request from './lib/Request';
6import CachedRequest from './lib/CachedRequest'; 6import CachedRequest from './lib/CachedRequest';
7import { gaEvent } from '../lib/analytics'; 7import { gaEvent } from '../lib/analytics';
8import { DEFAULT_APP_SETTINGS } from '../config';
9 8
10export default class SettingsStore extends Store { 9export default class SettingsStore extends Store {
11 @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings'); 10 @observable allSettingsRequest = new CachedRequest(this.api.local, 'getSettings');
@@ -18,10 +17,6 @@ export default class SettingsStore extends Store {
18 // Register action handlers 17 // Register action handlers
19 this.actions.settings.update.listen(this._update.bind(this)); 18 this.actions.settings.update.listen(this._update.bind(this));
20 this.actions.settings.remove.listen(this._remove.bind(this)); 19 this.actions.settings.remove.listen(this._remove.bind(this));
21
22 // this.registerReactions([
23 // this._shareSettingsWithMainProcess.bind(this),
24 // ]);
25 } 20 }
26 21
27 setup() { 22 setup() {
@@ -30,14 +25,14 @@ export default class SettingsStore extends Store {
30 } 25 }
31 26
32 @computed get all() { 27 @computed get all() {
33 return observable(Object.assign(DEFAULT_APP_SETTINGS, this.allSettingsRequest.result)); 28 return this.allSettingsRequest.result || {};
34 } 29 }
35 30
36 @action async _update({ settings }) { 31 @action async _update({ settings }) {
37 await this.updateSettingsRequest.execute(settings)._promise; 32 await this.updateSettingsRequest.execute(settings)._promise;
38 this.allSettingsRequest.patch((result) => { 33 await this.allSettingsRequest.patch((result) => {
39 if (!result) return; 34 if (!result) return;
40 Object.assign(result, settings); 35 extendObservable(result, settings);
41 }); 36 });
42 37
43 // We need a little hack to wait until everything is patched 38 // We need a little hack to wait until everything is patched