diff options
author | 2018-02-26 16:43:57 +0100 | |
---|---|---|
committer | 2018-02-26 16:43:57 +0100 | |
commit | d1e6f03395b4d2b668a8da6260aca8adf823f1db (patch) | |
tree | 7153ce10c48f1ba6453999bca8e4ba8a8aa410eb /src/stores | |
parent | initial commit (diff) | |
download | ferdium-app-d1e6f03395b4d2b668a8da6260aca8adf823f1db.tar.gz ferdium-app-d1e6f03395b4d2b668a8da6260aca8adf823f1db.tar.zst ferdium-app-d1e6f03395b4d2b668a8da6260aca8adf823f1db.zip |
ADD `features` request
REFACTOR `defaults` -> `base`
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 3 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 35 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index a5640e8d3..162422017 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -158,9 +158,6 @@ export default class AppStore extends Store { | |||
158 | this.locale = this._getDefaultLocale(); | 158 | this.locale = this._getDefaultLocale(); |
159 | 159 | ||
160 | this._healthCheck(); | 160 | this._healthCheck(); |
161 | |||
162 | const defaults = this.stores.features.defaults; | ||
163 | console.log(defaults) | ||
164 | } | 161 | } |
165 | 162 | ||
166 | @computed get cacheSize() { | 163 | @computed get cacheSize() { |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 5f738557f..817c2273f 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -5,14 +5,39 @@ import CachedRequest from './lib/CachedRequest'; | |||
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | 6 | ||
7 | export default class RecipesStore extends Store { | 7 | export default class RecipesStore extends Store { |
8 | @observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'defaults'); | 8 | @observable baseFeaturesRequest = new CachedRequest(this.api.features, 'base'); |
9 | @observable featuresRequest = new CachedRequest(this.api.features, 'features'); | ||
9 | 10 | ||
10 | setup() { | 11 | setup() { |
11 | return this.defaults; | 12 | this.registerReactions([ |
13 | this._monitorLoginStatus.bind(this), | ||
14 | this._debugFeatures.bind(this), | ||
15 | ]); | ||
12 | } | 16 | } |
13 | 17 | ||
14 | @computed get defaults() { | 18 | @computed get base() { |
15 | console.log('GETTING DEFAULTS') | 19 | return this.baseFeaturesRequest.execute().result || {}; |
16 | return this.defaultFeaturesRequest.execute().result || []; | 20 | } |
21 | |||
22 | @computed get features() { | ||
23 | if (this.stores.user.isLoggedIn) { | ||
24 | return this.featuresRequest.execute().result || {}; | ||
25 | } | ||
26 | |||
27 | return this.base; | ||
28 | } | ||
29 | |||
30 | _debugFeatures() { | ||
31 | console.log(this.base, this.features) | ||
32 | } | ||
33 | |||
34 | _monitorLoginStatus() { | ||
35 | if (this.stores.user.isLoggedIn) { | ||
36 | this.featuresRequest.invalidate({ immediately: true }); | ||
37 | this.featuresRequest.execute(); | ||
38 | } else { | ||
39 | this.baseFeaturesRequest.invalidate({ immediately: true }); | ||
40 | this.baseFeaturesRequest.execute(); | ||
41 | } | ||
17 | } | 42 | } |
18 | } | 43 | } |