aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-02-15 16:58:23 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-02-15 16:58:23 +0100
commitf265e39711546e14c08744f8e8a774046aa88d07 (patch)
treed8c99b0f9f60fdb8cdac85848dc066d28cbe8615 /src/stores
parentfeat(Windows): Add more app icon resolutions (@Stanzilla) (diff)
downloadferdium-app-f265e39711546e14c08744f8e8a774046aa88d07.tar.gz
ferdium-app-f265e39711546e14c08744f8e8a774046aa88d07.tar.zst
ferdium-app-f265e39711546e14c08744f8e8a774046aa88d07.zip
replace localStorage with mobx-localstorage
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/SettingsStore.js12
-rw-r--r--src/stores/UserStore.js4
2 files changed, 11 insertions, 5 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index da99a720f..26d895b7e 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -26,15 +26,19 @@ export default class SettingsStore extends Store {
26 } 26 }
27 27
28 @computed get all() { 28 @computed get all() {
29 console.log('get all settings');
29 return new SettingsModel(this.allSettingsRequest.result); 30 return new SettingsModel(this.allSettingsRequest.result);
30 } 31 }
31 32
32 @action async _update({ settings }) { 33 @action async _update({ settings }) {
33 await this.updateSettingsRequest.execute(settings)._promise; 34 await this.updateSettingsRequest.execute(settings)._promise;
34 await this.allSettingsRequest.patch((result) => { 35 // await this.allSettingsRequest.patch((result) => {
35 if (!result) return; 36 // if (!result) return;
36 extendObservable(result, settings); 37 // console.log(result.runInBackground, settings.runInBackground);
37 }); 38 // extendObservable(result, settings);
39 // console.log(result.runInBackground);
40 // // result.update(settings);
41 // });
38 42
39 // We need a little hack to wait until everything is patched 43 // We need a little hack to wait until everything is patched
40 setTimeout(() => this._shareSettingsWithMainProcess(), 0); 44 setTimeout(() => this._shareSettingsWithMainProcess(), 0);
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index abec4df5d..7b8ffb2b2 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -1,6 +1,7 @@
1import { observable, computed, action } from 'mobx'; 1import { observable, computed, action } from 'mobx';
2import moment from 'moment'; 2import moment from 'moment';
3import jwt from 'jsonwebtoken'; 3import jwt from 'jsonwebtoken';
4import localStorage from 'mobx-localstorage';
4 5
5import { isDevMode } from '../environment'; 6import { isDevMode } from '../environment';
6import Store from './lib/Store'; 7import Store from './lib/Store';
@@ -99,7 +100,7 @@ export default class UserStore extends Store {
99 100
100 // Data 101 // Data
101 @computed get isLoggedIn() { 102 @computed get isLoggedIn() {
102 return this.authToken !== null && this.authToken !== undefined; 103 return Boolean(localStorage.getItem('authToken'));
103 } 104 }
104 105
105 // @computed get isTokenValid() { 106 // @computed get isTokenValid() {
@@ -225,6 +226,7 @@ export default class UserStore extends Store {
225 226
226 // This is a mobx autorun which forces the user to login if not authenticated 227 // This is a mobx autorun which forces the user to login if not authenticated
227 _requireAuthenticatedUser = () => { 228 _requireAuthenticatedUser = () => {
229 console.log('requireAuthenticatedUser');
228 if (this.isTokenExpired) { 230 if (this.isTokenExpired) {
229 this._logout(); 231 this._logout();
230 } 232 }