aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/SettingsStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-02-15 17:38:13 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-02-15 17:38:13 +0100
commit9a89ef51cded72d5e6d378211e8a74964cfc8cc2 (patch)
treeee4c0d7913119d52b266f66f46d99ee9ef3b9ed8 /src/stores/SettingsStore.js
parentreplace localStorage with mobx-localstorage (diff)
downloadferdium-app-9a89ef51cded72d5e6d378211e8a74964cfc8cc2.tar.gz
ferdium-app-9a89ef51cded72d5e6d378211e8a74964cfc8cc2.tar.zst
ferdium-app-9a89ef51cded72d5e6d378211e8a74964cfc8cc2.zip
Replace localAPI requests with mobx-localstorage
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r--src/stores/SettingsStore.js21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index 26d895b7e..f6f340c2b 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,5 +1,6 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import { action, computed, observable, extendObservable } from 'mobx'; 2import { action, computed, observable, extendObservable } from 'mobx';
3import localStorage from 'mobx-localstorage';
3 4
4import Store from './lib/Store'; 5import Store from './lib/Store';
5import Request from './lib/Request'; 6import Request from './lib/Request';
@@ -26,19 +27,12 @@ export default class SettingsStore extends Store {
26 } 27 }
27 28
28 @computed get all() { 29 @computed get all() {
29 console.log('get all settings'); 30 return new SettingsModel(localStorage.getItem('app') || {});
30 return new SettingsModel(this.allSettingsRequest.result);
31 } 31 }
32 32
33 @action async _update({ settings }) { 33 @action async _update({ settings }) {
34 await this.updateSettingsRequest.execute(settings)._promise; 34 const appSettings = this.all;
35 // await this.allSettingsRequest.patch((result) => { 35 localStorage.setItem('app', Object.assign(appSettings, settings));
36 // if (!result) return;
37 // console.log(result.runInBackground, settings.runInBackground);
38 // extendObservable(result, settings);
39 // console.log(result.runInBackground);
40 // // result.update(settings);
41 // });
42 36
43 // We need a little hack to wait until everything is patched 37 // We need a little hack to wait until everything is patched
44 setTimeout(() => this._shareSettingsWithMainProcess(), 0); 38 setTimeout(() => this._shareSettingsWithMainProcess(), 0);
@@ -47,8 +41,11 @@ export default class SettingsStore extends Store {
47 } 41 }
48 42
49 @action async _remove({ key }) { 43 @action async _remove({ key }) {
50 await this.removeSettingsKeyRequest.execute(key); 44 const appSettings = this.all;
51 await this.allSettingsRequest.invalidate({ immediately: true }); 45 if (Object.hasOwnProperty.call(appSettings, key)) {
46 delete appSettings[key];
47 localStorage.setItem('app', appSettings);
48 }
52 49
53 this._shareSettingsWithMainProcess(); 50 this._shareSettingsWithMainProcess();
54 } 51 }